当前位置:   article > 正文

python-proxy_pyproxy

pyproxy

代码:

  1. # -*- coding: utf-8 -*-
  2. # @Time : 2020/4/15 17:44
  3. # @Author : Oneqq
  4. # @File : 11.proxy.py
  5. # @Software: PyCharm
  6. from urllib.request import Request, urlopen
  7. from fake_useragent import UserAgent
  8. from urllib.request import ProxyHandler, build_opener
  9. url = "https://www.jianshu.com"
  10. headers = {
  11. "User-Agent": UserAgent().chrome
  12. }
  13. request = Request(url, headers=headers)
  14. # handler = ProxyHandler({"http": "398707160:j8inhg2g@120.27.224.41:6818"})
  15. # 西刺免费代理 www.xicidaili.com
  16. handler = ProxyHandler({"http": "112.14.47.6:52024"})
  17. opener = build_opener(handler)
  18. response = opener.open(request)
  19. print(response.read().decode())

结果:

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/很楠不爱3/article/detail/287435
推荐阅读
相关标签
  

闽ICP备14008679号