标签:
conda install scrapy
scrapy startproject qiubai
#导入scrapy import scrapy #创建糗百爬虫类 class QiuBaiSpider(scrapy.Spider): #定义爬虫的名字 name = ‘qiubai‘ #定义爬虫开始的URL start_urls=[‘http://www.qiushibaike.com/‘,] #处理爬取的信息 def parse(self, response): li=response.xpath(‘//div[@class="author clearfix"]/a[2]/h2/text()‘).extract() #li=response.xpath("//h2/text()").extract() for item in li: print item
输入代码
from scrapy.cmdline import execute execute()
USER_AGENT = ‘Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.110 Safari/537.36‘
标签:
原文地址:http://www.cnblogs.com/yanhongjun/p/5361391.html