文章详情
接入指南 - 代码 - Python - aiohttp
#! -*- encoding:utf-8 -*-

import aiohttp, asyncio

# 要访问的目标页面
targetUrl = "http://www.quqiquqi.com/test"
# 请求切换IP(仅短效版、长效版用。动态版每次请求自动切换,无需指定)
# targetUrl = "http://www.quqiquqi.com/switch-ip"
# 查看当前隧道出口IP信息
# targetUrl = "http://www.quqiquqi.com/current-ip"

# 代理服务器
proxyHost = "tunnel.quqiquqi.com"
proxyPort = "8600"

# 代理隧道验证信息
proxyUser = "U123456789"
proxyPass = "P123456789"

proxyServer = "http://%(user)s:%(pass)s@%(host)s:%(port)s" % {
    "host" : proxyHost,
    "port" : proxyPort,
    "user" : proxyUser,
    "pass" : proxyPass,
}

userAgent = "curl/7.x/line"

async def entry():
    conn = aiohttp.TCPConnector(verify_ssl=False)

    async with aiohttp.ClientSession(headers={"User-Agent": userAgent}, connector=conn) as session:
        async with session.get(targetUrl, proxy=proxyServer) as resp:
            body = await resp.read()

            print(resp.status)
            print(body)

loop = asyncio.get_event_loop()
loop.run_until_complete(entry())
loop.run_forever()              
发布时间:2021-10-02

在线客服