构建一个刮板以异步刮刮多个页面。我创建了一个类,但是一旦我想运行测试方法,就会收到2个错误:
TypeError: 'coroutine' object is not callable
sys:1: RuntimeWarning: coroutine 'Scraper.page' was never awaited
这是我的代码:
from requests_html import AsyncHTMLSession
class Scraper(AsyncHTMLSession):
def __init__(self):
AsyncHTMLSession.__init__(self)
async def page(self):
t = await self.get("https://www.somePage.pl/strona/1/")
if __name__ == "__main__":
t = Scraper()
d1 = t.run(t.page())
print(d1.result)