aiohttp浣跨敤鏂规硶
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了aiohttp浣跨敤鏂规硶相关的知识,希望对你有一定的参考价值。
鏍囩锛?a href='http://www.mamicode.com/so/1/with' title='with'>with
ssi url ext sts div turn complete tpsimport aiohttp import asyncio async def request_jd_comment(session): url = "http://httpbin.org/ip" proxy = "http://14.67.8.20:2045" # 杩欓噷鐨勪唬鐞嗗弬鏁版槸proxy锛屽唴瀹规槸涓€涓猻tr锛屼緥濡?"http://14.67.8.20:2045")锛況equests璇锋眰鐨勪唬鐞嗗弬鏁版槸proxies锛屽唴瀹规槸涓€涓瓧鍏革紝渚嬪{"http": "http://14.67.8.20:2045", "https": "http://14.67.8.20:2045"} async with session.get(url, proxy=proxy) as response: return await response.text() async def crawl(): async with aiohttp.ClientSession() as session: result_content = await request_jd_comment(session) return result_content async def main(): result = await crawl() print(result) if __name__ == 鈥榑_main__鈥? loop = asyncio.get_event_loop() loop.run_until_complete(main())
銆€銆€
以上是关于aiohttp浣跨敤鏂规硶的主要内容,如果未能解决你的问题,请参考以下文章
浣跨敤IScroll缁勪欢鍑虹幇婊戝姩鍗¢闂瑙e喅鏂规硶
浣跨敤Python杩囩▼涓亣鍒扮殑涓€浜涘潙鍙婂叾瑙e喅鏂规硶锛堟寔缁洿鏂帮級