Web Scraping with BeautifulSoup and Requests py 01-02-2024, 02:52 AM
#1
import requests
from bs4 import BeautifulSoup
url = 'https://example.com'
response = requests.get(url)
soup = BeautifulSoup(response.text, 'html.parser')
# Extract all the links on the webpage
links = [a['href'] for a in soup.find_all('a', href=True)]
print("Links on the webpage:", links)
from bs4 import BeautifulSoup
url = 'https://example.com'
response = requests.get(url)
soup = BeautifulSoup(response.text, 'html.parser')
# Extract all the links on the webpage
links = [a['href'] for a in soup.find_all('a', href=True)]
print("Links on the webpage:", links)