阅读量:2
1、第一种方式使用cloudscraper绕过
import cloudscraper # 创建一个Cloudscraper实例,设置延迟和模拟的浏览器环境 scraper = cloudscraper.create_scraper(delay=5, browser={ 'browser': 'chrome', 'platform': 'linux', 'mobile': False, }) resp = scraper.get('https://toppsta.com/books/series/29278/national-geographic-kids-readers-level-1', # proxies={'http': 'http://127.0.0.1:10809', 'https': 'http://127.0.0.1:10809'} ) ## 打印响应的文本和状态码 print(resp.text) print(resp.status_code)
2、第二种方式使用curl_cffi绕过
from curl_cffi import requests as cffi_requests res = cffi_requests.get('https://toppsta.com/books/series/29278/national-geographic-kids-readers-level-1', impersonate='chrome110', timeout=10) print(res.text) print(res.status_code)