ssr4
ssr4
网站思路解析:
在这个网站中提示到有五秒延迟,所以我们在requests请求时只需要设定延迟时间即可。
代码如下:
import requests
headers = {
"Accept": "application/json, text/plain, */*",
"Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
"Cache-Control": "no-cache",
"Connection": "keep-alive",
"Pragma": "no-cache",
"Referer": "https://spa2.scrape.center/page/1",
"Sec-Fetch-Dest": "empty",
"Sec-Fetch-Mode": "cors",
"Sec-Fetch-Site": "same-origin",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36 Edg/113.0.1774.57",
}
def ssr3():
url = 'https://ssr4.scrape.center'
# 除了5秒延迟响应外,还要包括网速的问题,所在要多加3秒延迟
resp = requests.get(url=url, headers=headers, timeout=8).text
print(resp)
ssr3()
成功返回数据:
解决思路在解决一个反爬网站时起着至关重要的作用,所以在后面响应的结果解析就不在过多赘述,因为解析的规则相同都是用xpath来解析的,感兴趣的可以看前面的几篇关于解析代码。