Skip to content

Instantly share code, notes, and snippets.

@meejah
Created March 23, 2018 18:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save meejah/17d6327345a6a0a0b090cc0a0565e8e0 to your computer and use it in GitHub Desktop.
Save meejah/17d6327345a6a0a0b090cc0a0565e8e0 to your computer and use it in GitHub Desktop.
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()
)
@Pizzaben
Copy link

Pizzaben commented Jul 1, 2023

Hey😈

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment