查看: 1294|回复: 10
收起左侧

[求助交流] python简单代码分享

2020-4-9 17:45:19 | 显示全部楼层 |阅读模式
本帖最后由 xiaotaomi 于 2020-4-9 17:47 编辑

#! -*- encoding:utf-8 -*-        import requests     
   import random      
# 要访问的目标页面     
   targetUrl = "http://httpbin.org/ip"   
    # 要访问的目标HTTPS页面     
   # targetUrl = "https://httpbin.org/ip"  

      # 代理服务器(产品官网 www.16yun.cn)   
    proxyHost = "t.16yun.cn"      
  proxyPort = "31111"      
# 代理隧道验证信息      
  proxyUser = "username"   
     proxyPass = "password"   
     proxyMeta = "http://%(user)s:%(pass)s@%(host)s:%(port)s" % {            "host" : proxyHost,            "port" : proxyPort,      
      "user" : proxyUser,            "pass" : proxyPass,        }     
   # 设置 http和https访问都是用HTTP代理      
proxies = {            "http"  : proxyMeta,            "https" : proxyMeta,        }      
  #  设置IP切换头     
   tunnel = random.randint(1,10000)        headers = {"Proxy-Tunnel": str(tunnel)}   
     resp = requests.get(targetUrl, proxies=proxies, headers=headers)     
   print resp.status_code      
  print resp.text
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

热点推荐

关注我们,了解更多

官方微信

服务时间:10:00-16:00

13714503811

公司地址:深圳市龙岗区南湾街道东门头路8号

Copyright © 2012-2020 Powered by 树莓派论坛 2019.4  粤ICP备15075382号-1
快速回复 返回列表 返回顶部