Last active
May 4, 2016 14:31
-
-
Save derek-adair/bbb3d3087aba06d61439b0f79af49e13 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
#requires aiohttp - navigate to localhost:8080/?domain={domain_to_scrape} | |
from aiohttp import web | |
import aiohttp | |
import asyncio | |
async def handle(request): | |
domain = '//{}'.format(request.GET['domain']) | |
loop = asyncio.get_event_loop() | |
with aiohttp.ClientSession(loop=loop) as session: | |
print("fetching from {}".format(domain)) | |
async with session.get(domain) as resp: | |
content = await resp.text() | |
return web.Response(body=content.encode('utf-8')) | |
app = web.Application() | |
app.router.add_route('GET', '/', handle) | |
web.run_app(app) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment