main.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:PrivateSolution 作者: AdaJass 项目源码 文件源码
def fetchData(url, callback = pd.Xm, params=None):
    #set request url and parameters here or you can pass from outside.


    con = aiohttp.TCPConnector(limit=config.REQ_AMOUNTS)    
    s = aiohttp.ClientSession(headers = config.HEADERS, connector=con)
    #use s.** request a webside will keep-alive the connection automaticaly,
    #so you can set multi request here without close the connection 
    #while in the same domain.
    #i.e. 
    #await s.get('***/page1')
    #await s.get('***/page2')
    ########################################################################
    r=yield from s.get(url, params = params)
    #here the conection closed automaticly.
    data = yield from r.text(encoding='utf-8')    
    yield from callback(data)
    r.close()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号