python requests使用方法
2022-06-15 python 737
import requests url = "https://test.baidu.com/search?word[]={0}".format(word) with open("cookie.txt", "r", encoding="utf-8") as f: cookie_txt = f.read() headers = { "User-Agent": "Mozilla/5.0 (Linux;u;Android 4.2.2;zh-cn;) AppleWebKit/534.46(KHTML,like Gecko) Version/5.1 Mobile Safari/10600.6.3 (compatible;Baiduspider/2.0; +http://www.baidu.com/search/spider.html)", "Cookie": cookie_txt, "Connection": "close" } proxies = {} # proxies = { "http": "http://10.10.1.10:3128", "https": "http://10.10.1.10:1080", try: r = requests.get(url, headers=headers, proxies=proxies, timeout=10) if r.status_code == 200: content = r.content.decode() except Exception as e: print(str(e))
很赞哦! (0)
相关文章
文章评论
-
-
-
0条评论