如题:因为想试试代理ip,所以就想着在西刺上爬一些ip用用
如上两节所示,具体如何建立Scrapy工程的细节不在赘述。
scrapy startproject xici
scrapy genspider xici http://www.xicidaili.com/nn/
建立工程后,使用IDE打开,首先编辑item
#items.py
# -*- coding: utf-8 -*-
# Define here the models for your scraped items
#
# See documentation in:
# http://doc.scrapy.org/en/latest/topics/items.html
import scrapy
class XiciItem(scrapy.Item):
# define the fields for your item here like:
# name = scrapy.Field()
pass
class ipItem(scrapy.Item):
ip = scrapy.Field()<

本文讲述了使用Scrapy框架抓取西刺网站高匿代理IP时遇到的503错误问题,以及如何通过设置User-Agent解决这个问题。在Scrapy Settings.py中启用USER-AGENT,并在Scrapy shell中同样设置,以成功访问并爬取所需网页。
最低0.47元/天 解锁文章
1431

被折叠的 条评论
为什么被折叠?



