国产成人精品久久免费动漫-国产成人精品天堂-国产成人精品区在线观看-国产成人精品日本-a级毛片无码免费真人-a级毛片毛片免费观看久潮喷

您的位置:首頁(yè)技術(shù)文章
文章詳情頁(yè)

python 制作網(wǎng)站小說(shuō)下載器

瀏覽:16日期:2022-06-27 14:16:50
基本開(kāi)發(fā)環(huán)境

· Python 3.6

· Pycharm

相關(guān)模塊使用

python 制作網(wǎng)站小說(shuō)下載器

目標(biāo)網(wǎng)頁(yè)分析

python 制作網(wǎng)站小說(shuō)下載器

輸入想看的小說(shuō)內(nèi)容,點(diǎn)擊搜索

python 制作網(wǎng)站小說(shuō)下載器

這里會(huì)返回很多結(jié)果,我只選擇第一個(gè)

網(wǎng)頁(yè)數(shù)據(jù)是靜態(tài)數(shù)據(jù),但是要搜索,是post請(qǐng)求,需要提價(jià)data參數(shù),如下圖所示:

python 制作網(wǎng)站小說(shuō)下載器

然后通過(guò)解析網(wǎng)站數(shù)據(jù),獲取第一個(gè)小說(shuō)i的詳情頁(yè)url即可

靜態(tài)網(wǎng)頁(yè)的獲取,難度是不大的。

def search(): search_url = ’http://www.xbiquge.la/modules/article/waps.php’ data = {’searchkey’: name } response = requests.post(url=search_url, data=data, headers=headers) selector = get_parsing(response.text) novel_url = selector.css(’.even a::attr(href)’).extract_first()1、獲取每本小說(shuō)的章節(jié)名以及url地址

所有的章節(jié)名以及url地址,都包含在dd標(biāo)簽里面

python 制作網(wǎng)站小說(shuō)下載器

2、獲取url后,需要拼接

’/23/23019/11409705.html’ # 這是網(wǎng)頁(yè)獲取到的url’http://www.xbiquge.la/23/23019/11409705.html’ # 這是真實(shí)的小說(shuō)章節(jié)內(nèi)容url地址3、小說(shuō)名字,直接獲取即可。

def download_one_book(index_url): response = get_response(index_url) response.encoding = response.apparent_encoding sel = get_parsing(response.text) book_name = sel.css(’#info h1::text’).get() # 提取了所有章節(jié)的下載地址 urls = sel.css(’#list dd a::attr(href)’).getall() # 不要最新的 12 章放在最前main for url in urls:chapter_url = ’http://www.xbiquge.la’ + urlprint(chapter_url)

保存下載每章小說(shuō)內(nèi)容

def download_one_chapter(chapter_url, book_name): response = get_response(chapter_url) response.encoding = response.apparent_encoding html = response.text selector = get_parsing(html) h1 = selector.css(’.bookname h1::text’).get() content = selector.css(’#content::text’).getall() lines = [] for c in content:lines.append(c.strip()) print(h1) text = ’n’.join(lines) file = open(book_name + ’.txt’, mode=’a’, encoding=’utf-8’) file.write(h1) file.write(’n’) file.write(text) file.write(’n’) file.close()小說(shuō)軟件界面

root = Tk()root.title(’小說(shuō)下載器’)root.geometry(’560x450+400+200’) label = Label(root, text=’請(qǐng)輸入下載小說(shuō)名字:’, font=(’華文行楷’, 20))label.grid() entry = Entry(root, font=(’隸書’, 20))entry.grid(row=0, column=1) text = Listbox(root, font=(’隸書’, 16), width=50, heigh=15)text.grid(row=2, columnspan=2) button1 = Button(root, text=’開(kāi)始下載’, font=(’隸書’, 15), command=search)button1.grid(row=3, column=0) button2 = Button(root, text=’退出程序’, font=(’隸書’, 15), command=root.quit)button2.grid(row=3, column=1) root.mainloop()顯示下載內(nèi)容

def novel_load(title): text.insert(END, ’正在保存:{}’.format(title)) # 文本框滾動(dòng) text.see(END) # 更新 text.update()實(shí)現(xiàn)效果

python 制作網(wǎng)站小說(shuō)下載器

以上就是python 制作網(wǎng)站小說(shuō)下載器的詳細(xì)內(nèi)容,更多關(guān)于python 小說(shuō)下載器的資料請(qǐng)關(guān)注好吧啦網(wǎng)其它相關(guān)文章!

標(biāo)簽: Python 編程
相關(guān)文章:
主站蜘蛛池模板: 成人观看免费大片在线观看 | 精品国产美女福利到在线不卡 | 黑人巨大交牲老太 | 国产精品亚洲精品一区二区三区 | 综合在线播放 | 免费看孕妇毛片全部播放 | 窝窝午夜精品一区二区 | 欧美日韩国产一区二区三区播放 | 99热免费在线 | 欧美一级视频免费看 | 无套内谢孕妇毛片免费看 | 成人污网站 | 4四虎44虎www在线影院麻豆 | 2022国内精品免费福利视频 | 美女视频一区二区三区在线 | 中文国产成人精品久久一区 | aaa在线观看高清免费 | 欧美aaaaa激情毛片 | 真实国产乱人伦在线视频播放 | 成年午夜 | 99视频在线观看免费视频 | 精品国产乱码久久久久久一区二区 | 男女乱配视频免费观看 | 欧美一级aⅴ毛片 | 欧美一区视频 | 亚洲大片免费观看 | 国产美女自拍视频 | 国产成人精品一区二区视频 | 成人午夜看片在线观看 | m男亚洲一区中文字幕 | 国产一区二区三区免费 | 欧美大片一区 | 九九久久久| 一级特黄特色的免费大片视频 | 欧美一级影院 | 高清国产露脸捆绑01经典 | 久久国产精品无码网站 | 国产精品亚洲精品不卡 | 久草国产在线播放 | 99www综合久久爱com | 波多野结衣一区二区 三区 波多野结衣一区二区三区88 |