当前位置:   article > 正文

【无标题】爬取网页有反扒不能全部返回代码怎么办?_timeout hide-callback

timeout hide-callback
今天学习一个爬虫python 程序,需要爬取网页的源代码,结果怎么尝试都是失败,研究了几天还有一样没有进展
#使用爬虫到网上去爬一些数据
import requests
from lxml import etree
import os
#获取地址
url='https://baijiahao.baidu.com/s?'

data={
    'wd':'id=1761874515754793087'
}

headers={"User-Agent":
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36 Edg/119.0.0.0"}
#发送请求
resp=requests.get(url,params=data,headers=headers,proxies=proxy)
#使用utf-8解码
resp.encoding="utf-8"
输出
print(resp.text)

结果返回的只有是网络不给力: 

<div class="timeout hide-callback">
<div class="timeout-img"></div>
 <div class="timeout-title">网络不给力,请稍后重试</div>
 <button type="button" class="timeout-button">返回首页</button>

还有什么方法能够绕过反扒呢?

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小惠珠哦/article/detail/845658
推荐阅读
相关标签
  

闽ICP备14008679号