Skip to content

Instantly share code, notes, and snippets.

@zxyle
Created December 24, 2018 23:19
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 zxyle/992a9ce394d41b8ec1330a678089c20f to your computer and use it in GitHub Desktop.
Save zxyle/992a9ce394d41b8ec1330a678089c20f to your computer and use it in GitHub Desktop.
#!/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