爬蟲兩種繞過5s盾的方法

lvye001發表於2024-05-08
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)

相關文章