Created
March 23, 2018 18:52
-
-
Save meejah/17d6327345a6a0a0b090cc0a0565e8e0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import asyncio | |
import aiohttp | |
from aiosocks.connector import ProxyConnector, ProxyClientRequest | |
async def fetch(session, socks_port, url): | |
conn = ProxyConnector(remote_resolve=True) | |
async with aiohttp.ClientSession(connector=conn, request_class=ProxyClientRequest) as session: | |
request = session.get( | |
url, | |
proxy='socks5://127.0.0.1:{}'.format(socks_port), | |
headers={ | |
"Host": "timaq4ygg2iegci7.onion" | |
} | |
) | |
print(dir(request)) | |
async with request as resp: | |
print("Return status: {}".format(resp.status)) | |
print(dir(resp)) | |
print(resp.raw_headers) | |
if resp.status == 200: | |
data = await resp.text() | |
return data | |
return None | |
async def do_client_stuff(): | |
async with aiohttp.ClientSession() as session: | |
html = await fetch(session, 9050, 'http://timaq4ygg2iegci7.onion') | |
# html = await fetch(session, 9050, 'https://www.torproject.org') | |
print("got data:\n{}".format(html)) | |
if __name__ == '__main__': | |
asyncio.get_event_loop().run_until_complete( | |
do_client_stuff() | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey😈