資源簡介
實現python爬取小說
代碼片段和文件信息
#?-*-?coding:utf-8?-*-
import?re
import?requests
url?=?“http://mianzhuan.wddsnxn.org“
headers?=?{‘User-Agent‘:?‘Mozilla/5.0?(Windows?NT?6.1;?WOW64)?AppleWebKit/535.1?\
????(KABUL?like?Gecko)?Chrome/14.0.835.163?Safari/535.1‘}
params?=?{‘tickers‘:?‘MST‘?‘date‘:?‘2020-07-15‘}
response?=?requests.get(urlheaders=headersparams=params)
response.encoding=‘utf-8‘
html?=?response.text
#print(html)
#獲取小說的標題
title?=?re.findall(r‘?(.*?)? ‘html)
#print(title)
url?=?re.findall(r‘?.*??‘html)
#print(url)
#新建文件
fb?=?open(“note.txt“‘w‘encoding=‘utf-8-sig‘)
#for循環迭代?下載每一個章節
i?=?0
for?info?in?url:
????info_response?=?requests.get(infoheaders=headersparams=params)
????info_response.encoding?=?‘utf-8-sig‘
????info_html?=?info_response.text
#info_html
????#提取章節內容
????content?=?re.findall(r‘(.*?)ript?language=“javascript“.*?>‘info_html)
????#print(content)
????#清洗數據
????content=content[0].replace(“
““\n“)
????content?=?content.replace(“
“““)
????#
評論
共有 條評論
相關資源
- 彼岸花網壁紙爬蟲
- Python 爬蟲小說.ipynb
- 爬蟲爬取網易云音樂
- 北郵python爬蟲學堂在線
- python簡單爬蟲
- 爬取58同城二手房信息.py
- 知網爬蟲軟件(python)
- python爬蟲爬取微博熱搜
- python爬蟲爬取旅游信息(附源碼,c
- python爬蟲爬取豆瓣電影信息
- 爬取上百張妹子圖源碼可直接運行
- Python爬蟲實戰入門教程
- 網絡爬蟲(pachong_anjuke.py)
- Python-京東搶購助手包含登錄查詢商品
- python網絡爬蟲獲取景點信息源碼
- python爬取維基百科程序語言消息盒(
- python新浪微博爬蟲
- 12306爬蟲實現
- 中國裁判文書網爬蟲
- Python爬蟲相關書籍.zip
- 豆瓣電影排行爬蟲
- 疫情數據爬蟲并繪制柱狀圖.py
- python新浪微博爬蟲,爬取微博和用戶
- Python數據爬蟲及可視化分析
- 一套最新價值1680元的python爬蟲實戰全
- 測試工程師相關學習視頻(包含pyth
- 11-Python爬蟲工程師-App抓取進階
- 基于10000網頁python搭建搜索引擎課程設
- 法律判決文書python爬蟲、以及數據處
- python新浪微博爬蟲,爬取微博和用戶