TMMM

ip代理配置

 1 from urllib import request,parse
 2 
 3 url = "https://www.baidu.com/s?wd=ip"
 4 headers = {\'User-Agent\': \'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.80 Safari/537.36\'}
 5 
 6 # 创建一个请求对象
 7 req = request.Request(url=url,headers=headers)
 8 
 9 # 创建一个handler
10 handler = request.ProxyHandler({"http":\'122.241.88.79:15872\'})
11 
12 # 创建一个opener携带handler
13 opener = request.build_opener(handler)
14 
15 # 用opener发起请求
16 res = opener.open(req)
17 
18 # 写入文件中
19 with open("ip.html",\'wb\') as fp:
20     fp.write(res.read())

 

分类:

技术点:

相关文章:

  • 2022-02-10
  • 2021-12-02
  • 2021-12-24
  • 2021-11-01
  • 2021-04-18
  • 2022-02-10
  • 2021-06-16
  • 2021-12-06
猜你喜欢
  • 2021-11-15
  • 2021-11-30
  • 2021-11-06
  • 2021-11-21
  • 2021-05-13
  • 2021-08-18
相关资源
相似解决方案