写爬虫变成了这样:
from gspider.base import BaseSpider
from gspider.fields import PQField
class PythonDocSpider(BaseSpider):
title = PQField('h1') # select `h1` element from the page, you can use other css selectors too
content = PQField('p')
spider = PythonDocSpider(
'https://docs.python.org/3/library/base64.html'
)
>>> print(spider.title)
>>> 19.6. base64 — Base16, Base32, Base64, Base85 Data Encodings ¶
安装:
git clone https://github.com/ericls/gspider
cd gspider
python setup.py install
或者直接 clone 进自己的脚本目录,再解决requests
和pyquery
两个依赖
更多信息:
Project Name: Gspider. (Pretty random name, isn't it?)
GitHub Repo: __https://github.com/ericls/gspider__
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。