'Asynchronous Requests Error "object of type 'method' has no len()" - Python, BS4 & asyncio/aiohttp
Hi so I'm working on a web scraper that loops through a list of URLS and returns true if the URL is not owned by an active users account, and false if the URL is in use by an account. The process was too slow with the requests library so I opted to use asyncio and aiohttp instead to run the scraper asynchronously. However I'm at a part in my code where I am receiving the following error: elif len(markup) <= 256 and ( TypeError: object of type 'method' has no len(). The console states the error is due to lines 33, 44, and 49, but I have no idea why this error is thrown. Another user suggested it may be due to missing brackets in my calls, but I have called all functions correctly.
Any help is greatly appreciated. Thank you
Solution 1:[1]
Replace
soup = BeautifulSoup(response.text, "lxml")
with
soup = BeautifulSoup(await response.text(), "lxml")
Please read documentation carefully.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Andrew Svetlov |
