(我与爬虫的较量)码上爬第三题

题目地址:https://www.mashangpa.com/problem-detail/3/

这里作者很有意思,当我想F12调试的时候,就出现了

典型的JS禁用了调试工具,我们通过手动的进入浏览器-->更多工具-->开发者工具

出现了这个,一定是在强制打开后发生了什么,经过全局搜索debugger后

这里即使禁止了debugger,但是还是会发生页面自毁,主要因为会检测开发者工具的检测

解决办法:打开这个设备仿真(原理就是更改页面显示的大小)

复制代码
import requests



headers = {
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36 Edg/139.0.0.0",
    "Referer": "https://www.mashangpa.com/problem-detail/1/",
    "Accept": "*/*",
    "Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
    "Accept-Encoding": "gzip, deflate, br, zstd",
    "Cookie": "yours Cookie"
}
sum_all = 0
for i in range(1, 21):
    url = f"https://www.mashangpa.com/api/problem-detail/3/data/?page={i}"
    resp = requests.get(url, headers=headers)
    # print(resp.status_code)
    arr = resp.json()['current_array']
    total = sum(arr)
    sum_all+=total
url = f"https://www.mashangpa.com/api/problem-detail/2/data/?page=2"
resp = requests.get(url, headers=headers)
print(sum_all)
相关推荐
q***25115 小时前
Python中的简单爬虫
爬虫·python·信息可视化
Glommer21 小时前
简单聊一下 tls 指纹校验
爬虫·浏览器
xinxinhenmeihao1 天前
爬虫为什么要用动态ip?动态IP在爬虫中起到哪些作用?
爬虫·网络协议·tcp/ip
APIshop1 天前
代码解析:通过第三方爬虫获取1688商品详情接口
爬虫·okhttp
深蓝电商API2 天前
初级爬虫反爬应对:解决 403、IP 限制的简单方法
爬虫·python
深蓝电商API2 天前
爬虫速度优化:初级阶段如何提升爬取效率(无复杂操作)
爬虫
芝麻开门-新起点2 天前
贝壳的反爬虫机制深度解析
爬虫
q***T5832 天前
MySQL爬虫
数据库·爬虫·mysql
木子杳衫2 天前
【爬虫项目】大众点评电影数据爬虫实战
爬虫
T***16072 天前
JavaGraphQLAPI
爬虫·objective-c·rizomuv