爬虫两种绕过5s盾的方法

import cloudscraper

proxies = {
    "http": "http://127.0.0.1:7890",
    "https": "http://127.0.0.1:7890",
}
headers = {
    'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36',
}
url = 'https://xxx'
scraper = cloudscraper.create_scraper()
response = scraper.get(url, proxies=proxies,headers=headers)
print(response.text)

 

from curl_cffi import requests as curl_req
proxies = {
    "http": "http://127.0.0.1:7890",
    "https": "http://127.0.0.1:7890",
}
headers = {
    'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36',
}
url = 'https://xxx'
res = curl_req.get(url=url,headers=headers,proxies=proxies)
print(res.text)

 

posted @ 2024-05-08 16:49  lvye001  阅读(287)  评论(0编辑  收藏  举报