11、爬虫-代理

 

"""
通过第三方的ip去请求
"""

import requests
#8.130.39.155:3389
proxies = {
    "https":"http://58.20.248.139:9002",
}
headers = {
    "User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
}

#使用代理去请求
resp = requests.get("http://www.baidu.com",proxies=proxies)
resp.encoding = 'utf-8'
print(resp.text)
posted @ 2024-07-01 22:26  little小新  阅读(121)  评论(0编辑  收藏  举报