今天学习一个爬虫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>
还有什么方法能够绕过反扒呢?