资源简介
关于小说的简易爬虫,仅供大家进行学习参考,有问题可以一块讨论
代码片段和文件信息
import requests
from bs4 import BeautifulSoup
import sys
import time
class download(object):
def __init__(self):
self.server = ‘https://www.biqukan.com‘
self.target = ‘https://www.biqukan.com/1_1094/‘
self.names = []
self.nums = 0
self.urls = []
self.headers = { ‘Accept‘: ‘text/htmlapplication/xhtml+xmlapplication/xml;q=0.9*/*;q=0.8‘
‘Accept-Encoding‘: ‘gzip deflate br‘
‘Accept-Language‘: ‘zh-CNzh;q=0.8en-US;q=0.5en;q=0.3‘
‘Connection‘: ‘keep-alive‘
‘user-agent‘: ‘Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML like Gecko) Chrome/44.0.2403.157 Safari/537.36‘
}
“““
函数说明:获取下载链接
Parameter:
无
Return:
无
Modify:
2018-12-08
“““
def get_download_url(self):
req = requests.get(self.targetheaders = self.headers)
html = req.text
div_bf = BeautifulSoup(html‘html5lib‘)
div = div_bf.find_all(‘div‘class_=‘listmain‘)
a_bf = BeautifulSoup(str(div[0])‘html5lib‘)
a = a_bf.find_all(‘a‘)
self.nums = len(a[15:])
for each in a[15:]:
if each.string==“正文“ or each.string==“正文卷“:
continue
self.names.append(each.string)
self.urls.append(self.server+each.get(‘href‘))
“““
函数说明:获取章节内容
Parmeters:
target - 下载链接(string)
Returns:
texts - 章节内容(string)
Modify:
2018-12-08
相关资源
- 二级考试python试题12套(包括选择题和
- pywin32_python3.6_64位
- python+ selenium教程
- PycURL(Windows7/Win32)Python2.7安装包 P
- 英文原版-Scientific Computing with Python
- 7.图像风格迁移 基于深度学习 pyt
- 基于Python的学生管理系统
- A Byte of Python(简明Python教程)(第
- Python实例174946
- Python 人脸识别
- Python 人事管理系统
- 基于python-flask的个人博客系统
- 计算机视觉应用开发流程
- python 调用sftp断点续传文件
- python socket游戏
- 基于Python爬虫爬取天气预报信息
- python函数编程和讲解
- Python开发的个人博客
- 基于python的三层神经网络模型搭建
- python实现自动操作windows应用
- python人脸识别(opencv)
- python 绘图(方形、线条、圆形)
- python疫情卡UN管控
- python 连连看小游戏源码
- 基于PyQt5的视频播放器设计
- 一个简单的python爬虫
- csv文件行列转换python实现代码
- Python操作Mysql教程手册
- Python Machine Learning Case Studies
- python获取硬件信息
评论
共有 条评论