someone know how to do :
import html5lib
import urllib
from bs4 import BeautifulSoup
soup = BeautifulSoup(urllib.request.urlopen('http://someWebSite.com').read().decode('utf-8'), 'html5lib')
using aiohttp instead of urllib ?
Thanks ^^
You can do something like this:
import asyncio
import aiohttp
import html5lib
from bs4 import BeautifulSoup
SELECTED_URL = 'http://someWebSite.com'
async def get_site_content():
async with aiohttp.ClientSession() as session:
async with session.get(SELECTED_URL) as resp:
text = await resp.read()
return BeautifulSoup(text.decode('utf-8'), 'html5lib')
loop = asyncio.get_event_loop()
sites_soup = loop.run_until_complete(get_site_content())
print(sites_soup)
loop.close()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With