parsing HTML response

PHOTO EMBED

Wed Apr 12 2023 15:18:23 GMT+0000 (Coordinated Universal Time)

Saved by @adebola

import requests

from bs4 import BeautifulSoup as bs

raw_req = requests.get("http://adebola.pythonanywhere.com").text

soup = bs(raw_req, 'html')

page_code = soup.prettify()

#.prettify will display the html code in a readable and distinct manner.

label_tags = soup.findAll("label")

#.findAll("label") returns a list of all label tags on the page.

link_tags = soup.findAll("a")

#a list of all anchor tags

link= [i["href"] for i in linktags]

#a list containing only the href attributes of the anchor tags.

labels= [i.text for i in labels]

#returns a list of the label texts in the label tags.
content_copyCOPY