from bs4 import BeautifulSoup import requests url = 'https://www.example.com' response = requests.get(url) soup = BeautifulSoup(response.text, 'html.parser') print(soup)
from bs4 import BeautifulSoup import requests url = 'https://www.example.com/table' response = requests.get(url) soup = BeautifulSoup(response.text, 'html.parser') table = soup.find('table') rows = table.find_all('tr') for row in rows: cols = row.find_all('td') for col in cols: print(col.text)This code downloads an HTML table from the given URL and extracts the data from each cell using BeautifulSoup's `find` and `find_all` methods. The resulting text is printed to the console. Package library: `beautifulsoup4`