作者: laical123456
查看: 662|回复: 0
打印 上一主题 下一主题

[讨论] 爬虫代码

[复制链接]
跳转到指定楼层
楼主
laical123456 发表于 2021-6-10 16:32:14 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
查看: 662|回复: 0
本帖最后由 laical123456 于 2021-6-10 17:10 编辑

[AppleScript] 纯文本查看 复制代码
    #! -*- 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
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 转播转播
回复 论坛版权

使用道具 举报

您需要登录后才可以回帖 登录 | 加入CSkin博客

本版积分规则

QQ|申请友链|小黑屋|手机版|Archiver|CSkin ( 粤ICP备13070794号

Powered by Discuz! X3.2  © 2001-2013 Comsenz Inc.  Designed by ARTERY.cn
GMT+8, 2024-4-25 11:49, Processed in 0.724868 second(s), 29 queries , Gzip On.

快速回复 返回顶部 返回列表