How do i webscrape an attribute from a tag?

Question:

I only need the value "Central Bank Digital Currency (CBDC) Tracker" to show up. However im getting a bunch of other attributes when i run my code. Im using the cbdctracker.org website.

import requests

from bs4 import BeautifulSoup

URL = "https://cbdctracker.org/"

response = requests.get(URL)
website_html = response.text

soup= BeautifulSoup(website_html, "html.parser")
#print(soup)

res = soup.find_all('meta')
res[6]

#print(res)

soup.attrs={"content": "twitter:title"}
print(res[6])
Asked By: Safiyah

||

Answers:

Try:

import requests
from bs4 import BeautifulSoup

URL = "https://cbdctracker.org/"

response = requests.get(URL)
website_html = response.text

soup = BeautifulSoup(website_html, "html.parser")
print(soup.select_one('meta[name="twitter:title"]')["content"])

Prints:

Central Bank Digital Currency (CBDC) Tracker
Answered By: Andrej Kesely