Python requests
- import requests
- targetURL = "https://ip.hahado.cn/api/index?ip=&type=0"
- proxyAddr = "您的代理IP:端口"
- authKey = "请改成您的Key"
- password = "请改成您的AuthPwd"
- # 账密模式
- proxyUrl = "http://%(user)s:%(password)s@%(server)s" % {
- "user": authKey,
- "password": password,
- "server": proxyAddr,
- }
- proxies = {
- "http": proxyUrl,
- "https": proxyUrl,
- }
- resp = requests.get(targetURL, proxies=proxies)
- print(resp.text)
Python aiohttp
- import aiohttp,asyncio
- targetURL = "https://ip.hahado.cn/api/index?ip=&type=0"
- proxyAddr = "您的代理IP:端口"
- authKey = "请改成您的Key"
- password = "请改成您的AuthPwd"
- # 账密模式
- proxyUrl = "http://%(user)s:%(password)s@%(server)s" % {
- "user": authKey,
- "password": password,
- "server": proxyAddr,
- }
- async def entry():
- conn = aiohttp.TCPConnector(ssl=False)
- async with aiohttp.ClientSession(connector=conn) as session:
- async with session.get(targetURL, proxy=proxyUrl) as resp:
- body = await resp.read()
- print(resp.status)
- print(body)
- loop = asyncio.get_event_loop()
- loop.run_until_complete(entry())
- loop.run_forever()