婷婷综合国产,91蜜桃婷婷狠狠久久综合9色 ,九九九九九精品,国产综合av

主頁 > 知識庫 > python 制作網(wǎng)站小說下載器

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

熱門標簽:騰訊地圖標注有什么版本 鎮(zhèn)江人工外呼系統(tǒng)供應商 柳州正規(guī)電銷機器人收費 千呼ai電話機器人免費 申請辦個400電話號碼 外呼系統(tǒng)前面有錄音播放嗎 高德地圖標注字母 深圳網(wǎng)絡外呼系統(tǒng)代理商 400電話辦理費用收費

基本開發(fā)環(huán)境

· Python 3.6

· Pycharm

相關模塊使用

目標網(wǎng)頁分析

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

這里會返回很多結果,我只選擇第一個

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

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

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

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、獲取每本小說的章節(jié)名以及url地址

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

2、獲取url后,需要拼接

'/23/23019/11409705.html' # 這是網(wǎng)頁獲取到的url
'http://www.xbiquge.la/23/23019/11409705.html' # 這是真實的小說章節(jié)內(nèi)容url地址

3、小說名字,直接獲取即可。

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' + url
        print(chapter_url)

保存下載每章小說內(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()

小說軟件界面

root = Tk()
root.title('小說下載器')
root.geometry('560x450+400+200')
 
label = Label(root, text='請輸入下載小說名字:', 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='開始下載', 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))
    # 文本框滾動
    text.see(END)
    # 更新
    text.update()

實現(xiàn)效果

以上就是python 制作網(wǎng)站小說下載器的詳細內(nèi)容,更多關于python 小說下載器的資料請關注腳本之家其它相關文章!

您可能感興趣的文章:
  • Python實現(xiàn)壁紙下載與輪換
  • Python 下載Bing壁紙的示例
  • python實現(xiàn)壁紙批量下載代碼實例
  • 編寫Python腳本批量下載DesktopNexus壁紙的教程
  • python批量下載壁紙的實現(xiàn)代碼
  • python Requsets下載開源網(wǎng)站的代碼(帶索引 數(shù)據(jù))
  • 用Python自動下載網(wǎng)站所有文件
  • python批量下載網(wǎng)站馬拉松照片的完整步驟
  • python抓取網(wǎng)站的圖片并下載到本地的方法
  • Python 批量下載陰陽師網(wǎng)站壁紙

標簽:郴州 烏蘭察布 平頂山 烏蘭察布 合肥 大慶 海南 哈爾濱

巨人網(wǎng)絡通訊聲明:本文標題《python 制作網(wǎng)站小說下載器》,本文關鍵詞  python,制作,網(wǎng)站,小說,下載,;如發(fā)現(xiàn)本文內(nèi)容存在版權問題,煩請?zhí)峁┫嚓P信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《python 制作網(wǎng)站小說下載器》相關的同類信息!
  • 本頁收集關于python 制作網(wǎng)站小說下載器的相關信息資訊供網(wǎng)民參考!
  • 推薦文章
    主站蜘蛛池模板: 嘉鱼县| 鹤岗市| 嘉善县| 滦平县| 旺苍县| 双鸭山市| 汕尾市| 乌恰县| 陈巴尔虎旗| 旬阳县| 龙州县| 舟曲县| 四川省| 晴隆县| 武平县| 怀安县| 淮滨县| 宜春市| 金寨县| 游戏| 济南市| 澜沧| 达日县| 吉水县| 怀安县| 紫云| 洪江市| 永寿县| 黄陵县| 镇远县| 西峡县| 灯塔市| 平利县| 海安县| 六安市| 札达县| 建宁县| 姚安县| 应用必备| 南召县| 新野县|