爬虫爬取小说(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()