Python 3 BeautifulSoup4 Script to Extract All Links Under List Tag in HTML5 Webpage Full Project For Beginners

 

 

pip install bs4

 

 

 

app.py

 

 

import requests
from bs4 import BeautifulSoup
url = 'https://www.python.org/'
reqs = requests.get(url)
soup = BeautifulSoup(reqs.text, 'lxml')

urls = []
for h in soup.find_all('li'):
    a = h.find('a')
    urls.append(a.attrs['href'])
print(urls)

Leave a Reply