您的位置:首页 > 其它

采集笔趣阁小说详情页内容

2019-07-02 08:35 155 查看
版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。 本文链接:https://blog.csdn.net/shanying1991/article/details/94428232

目标站地址:http://www.biquges.cc/b2922/
代码如下:
#coding=utf-8
import requests,re
class GetDes:
def gettitle(self,str):
“”"
获取小说标题
:param str:
:return:
“”"
get_title=re.compile(r’.*最新章节’)<br/> title=get_title.findall(str)[0]<br/> lis=re.split(r’[>\(]’,title)<br/> title=lis[1]<br/> return title

def getauthor(self,str):
"""
获取小说作者
:param str:
:return:
"""
get_author=re.compile(r'者:.*</p>')
author=get_author.findall(str)[0]
lis=re.split(r'[\:\<]',author)
author=lis[1]
# print(author)
return author

def getdesc(self,str):
"""
获取小说简介
:param str:
:return:
"""
get_desc=re.compile(r'description" content=".*\/\>')
desc=get_desc.findall(str)
print(desc)

def getdes(self):
"""
采集圣墟
:return:
"""
url='http://www.biquges.cc/b2922/'
url_two='http://www.9kzww.com/shu12/'
if requests.get(url).status_code==200:
con=requests.get(url)
#解决中文乱码问题
con.encoding='gbk'
cont=con.text
# title=self.gettitle(cont)
# print(title)
# author=self.getauthor(cont)
# print(author)
desc=self.getdesc(cont)
print(desc)
# print(cont)
else:
return ''

if name==“main”:
gd=GetDes()
gd.getdes()

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: