爬虫爬取小说(pyquery)

from pyquery import PyQuery
import requests
def crawle():
    url = 'https://www.qtshu.com/zetianji/'
    req = requests.get(url=url)
    req.encoding = 'utf-8'
    pq = PyQuery(req.content)
    lista = pq.find('li')
    print (len(lista))
    for aa in lista.items():
        print (aa.text(), aa.find('a').attr('href'))
crawle()

 

posted @ 2019-06-13 10:27  啦啦啦天啦噜  阅读(383)  评论(0编辑  收藏  举报