从一个或多个URL提取HTML
lurk的Python项目详细描述
从符合某种css模式的网页中提取html的脚本。
$ pip install lurk
用法
在python中
在python中,潜伏返回字典:
from lurk import lurk for link in lurk('http://en.wikipedia.org/wiki/en', 'a'): if 'href' in link: print link['href']
在bash中
在bash中,潜伏返回json。
$ lurk \ http://www.gnu.org/software/libc/manual/html_node/Function-Index.html \ 'a[href*="#index-"]' \ > links.json
此命令将包含指向所有gnu c函数的链接数组的json对象保存到links.json中
[
{
"code": "*pthread_getspecific",
"href": "Thread_002dspecific-Data.html#index-_002apthread_005fgetspecific"
},
{
"code": "*sbrk",
"href": "Resizing-the-Data-Segment.html#index-_002asbrk"
},
// ...
]