Created
December 24, 2018 23:19
-
-
Save zxyle/992a9ce394d41b8ec1330a678089c20f 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
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
# Author: Zheng <me@zxyle.cn> | |
# Desc | |
from aiohttp import web, ClientSession | |
async def fetch(session, url): | |
async with session.get(url) as response: | |
return await response.text() | |
async def main(url): | |
async with ClientSession() as session: | |
html = await fetch(session, url) | |
print(html) | |
async def handle(request): | |
doc_id = request.match_info.get('doc_id', "20e180db-ec69-45eb-b0f1-a81201016271") | |
# doc_id = self.get_argument("doc_id") | |
# url = "http://wenshu.court.gov.cn/CreateContentJS/CreateContentJS.aspx?DocID=20e180db-ec69-45eb-b0f1-a81201016271" | |
url = "http://wenshu.court.gov.cn/CreateContentJS/CreateContentJS.aspx?DocID={}".format(doc_id) | |
print(url) | |
await main(url) | |
return web.Response(text="1") | |
app = web.Application() | |
app.add_routes([web.get('/', handle), | |
web.get('/{doc_id}', handle)]) | |
web.run_app(app) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment