搜索(包括小說網址、名稱、作者姓名),下載為TXT文本
# 下載模塊
search_real_url = 'https://www.biquge5200.com/modules/article/search.php?searchkey=' + book_name
try:
novel_source = requests.get(search_real_url).text
reg1 = r'<td class="odd"><a href="https://bbs.csdn.net/topics/(.*?)">(.*?)</a></td>.*?<td class="odd">(.*?)</td>'
# 所有搜索到的結果(包括小說網址、名稱、作者姓名)
novel_list = re.findall(reg1, novel_source, re.S)
# 判斷是否有資料回傳
if len(novel_list) == 0:
print('搜索不到你要的小說')
except Exception as e:
print(e)
for novel_url, novel_name, novel_author in novel_list:
if novel_name == book_name:
print('書名:%s 作者:%s' % (novel_name, novel_author))
return novel_url, novel_name
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/38911.html
標籤:HTML5
