使用requestshtml如何在循环中创建异步函数并在单次运行函数时调用它们

2024-05-29 03:29:13 发布

您现在位置:Python中文网/ 问答频道 /正文

我希望能够创建尽可能多的async函数,并使用requests-html库一次性运行它们

from requests_html import AsyncHTMLSession

asession = AsyncHTMLSession()
number=5
for i in range(1,number):
    async def get_pythonorg():
        r = await asession.get('site/{}'.format(i))
        return r

results = asession.run(call All the above created functions called by a loop)


Tags: 函数infromimportnumberforgetasync

热门问题