from lxml import etree
from cookies_and_headers import cookies, headers
# def get_chap_dict(homep,client):
# response = client.get(homep, cookies=cookies, headers=headers)
# url_prefix = r"https://cn.baozimh.com"
# html = etree.HTML(response.text)
# result_pages = html.xpath("//a[@class='comics-chapters__item']/@href")
# result_names = html.xpath("//a[@class='comics-chapters__item']//span/text()")
# result_pages = [url_prefix + i for i in result_pages]
# resp = dict(zip(result_names,result_pages))
# return resp
# 重写,因为接入flaresolverr
post_body = {
"cmd": "request.get",
"url": "https://www.petsathome.com/",
"maxTimeout": 60000,
}
def get_chap_dict(homep, client, session):
post_body = {"cmd": "request.get", "url": homep, "maxTimeout": 60000}
if session == None:
response_raw = client.post(
"http://127.0.0.1:8191/v1",
cookies=cookies,
headers=headers,
json=post_body,
timeout=None,
)
else:
post_body = {
"cmd": "request.get",
"url": homep,
"maxTimeout": 60000,
"session": session,
}
response_raw = client.post(
"http://127.0.0.1:8191/v1",
cookies=cookies,
headers=headers,
json=post_body,
timeout=None,
)
response = (response_raw.json())["solution"]["response"]
url_prefix = r"https://cn.baozimh.com"
html = etree.HTML(response)
result_pages = html.xpath("//a[@class='comics-chapters__item']/@href")
result_names = html.xpath("//a[@class='comics-chapters__item']//span/text()")
result_pages = [url_prefix + i for i in result_pages]
resp = dict(zip(result_names, result_pages))
challengesolve = (response_raw.json())["solution"]
return resp, challengesolve
JJJ69
- 粉丝: 6364
- 资源: 5917
最新资源
- 基于鸿蒙期末大作业源码+文档+高分项目+全部资料.zip
- 基于开源设计与开发课程期末作业源码+文档+高分项目+全部资料.zip
- 基于进销存系统UML建模 面向对象系统分析期末大作业源码+文档+高分项目+全部资料.zip
- 基于开发与实践XM12期末大作业源码+文档+高分项目+全部资料.zip
- 基于前端期末大作业一个静态的电影网站源码+文档+高分项目+全部资料.zip
- 基于前端期末大作业源码+文档+高分项目+全部资料.zip
- 基于opencv的疲劳检测系统(django)源代码(完整前后端+mysql+说明文档+LW).zip
- libreOffice 麒麟信创环境依赖
- 基于贝叶斯网络的城市火灾预测方法源代码(完整前后端+mysql+说明文档+LW).zip
- 基于期末分布式系统大作业源码+文档+高分项目+全部资料.zip
- 基于软件与微电子学院 操作系统与虚拟化安全期末大作业源码+文档+高分项目+全部资料.zip
- 基于软件与微电子学院 数据挖掘期末作业源码+文档+高分项目+全部资料.zip
- 基于软件质量保证与测试 —— 课程实验代码+期末复习资料+期末实验大作业测试报告源码+文档+高分项目+全部资料.zip
- 基于深度学习期末大作业源码+文档+高分项目+全部资料.zip
- 基于数据库期末大作业源码+文档+高分项目+全部资料.zip
- 基于数据库课程设计期末大作业,利用sql sever2018 进行建库,利用python处理后端程序,flask搭建前端源码+文档+高分项目+全部资料.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈