目录
前言
小说看不过瘾,下载下来慢慢看,python爬虫五分钟轻松下载小说_novel is so frustrating!
函数介绍
函数功能简单介绍
库函数介绍
import requests#请求网页
from lxml import etree#对网页进行解析
函数功能介绍
函数1
def getdata(url):
html=requests.get(url).text
# print(html)
doc=etree.HTML(html)#构造xpath的解析对象
contents=doc.xpath('//*[@class="cf"]/li')
# print(contents)
for content in contents:
links=content.xpath('h2/a/@href')
for link in links:
hurl="https:"+link#小说某一章的网址
html=requests.get(hurl).text#获取到源代码
doc=e