Scrapy安装

1Pip install wheel

2pip install 复制路径+文件名Twisted-18.7.0-cp36-cp36m-win_amd64.whl

3Pip install scrapy

https://germey.gitbooks.io/python3webspider/content/1.8.2-Scrapy%E7%9A%84%E5%AE%89%E8%A3%85.html

4 win7api的加   pip install 复制路径+文件名pywin32-223.1-cp36-cp36m-win_amd64.whl

 

创建项目

 

1,scrapy startproject scrapy_project

 

创建spider,

2,cd scrapy_project

 

3,scrapy genspider bole jobbole.com

#bole jobbole.com 一个是文件名 一个是网站名

 

创立一个文件夹 main  里面

from scrapy.cmdline import execute
execute('scrapy crawl bole'.split())

#bole是文件名 

 

setting 里面的Trun改成False

 

通过xpath获取内容, xpath返回的元素内容是selector:

zan = response.xpath('//h10[@id="89252votetotal"]/text()').extract_first()

 

posted on 2018-08-23 21:32  卧铺车—站  阅读(80)  评论(0编辑  收藏  举报