[AppleScript] 纯文本查看 复制代码
#! -*- encoding:utf-8 -*-
import aiohttp, asyncio
targetUrl = "http://httpbin.org/ip"
# 代理服务器(产品官网 www.16yun.cn)
proxyHost = "t.16yun.cn"
proxyPort = "31111"
# 代理验证信息
proxyUser = "username"
proxyPass = "password"
proxyServer = "http://%(user)s:%(pass)s@%(host)s:%(port)s" % {
"host" : proxyHost,
"port" : proxyPort,
"user" : proxyUser,
"pass" : proxyPass,
}
userAgent = "Chrome/83.0.4103.61"
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()