常见问题
用python爬取笔趣阁小说
hl = zhuanhuan(url)
selector = html.fromstring(hl)
selector = html.fromstring(hl)
可以将每个标签点一下它对应的内容就会在网站里高亮。如图我现在点到了第一章的章节信息它内里包罗了每一章的链接与名称。
htmls_list.append(url + i)
hl = hl.content.decode("utf-8") # 源码变为字符串
url ='http://www.xbiquge.la/7/7004/'
#将链接与网页网址毗连形成每一章的网址
import requests,os
name_book = list[0]
print("爬取完成!")
htmls_list = []#建立一个空列表来存储所有章节链接
with open(name_book + r'/'+ chapter+'.txt',"w",encoding= "utf-8") as f:
name_book = list[0]
return htmls_list,name_list
f.write(txt)
list = selector.xpath('//div[@id = "info"]/h1/text()')
name_book = list[0]
txt = ''
def main(url):
main(url)
os.makedirs(name_book,exist_ok=True)
name = j.replace("?",'').replace('*','').replace('/','')#章节名称
y = list_fun(hl,url)
hl = hl.content.decode("utf-8")
name_list = selector.xpath('//div[@id = "list"]/dl/dd/a/text()')
url = 'http://www.xbiquge.la/7/7004/3246381.html'