Answer the question
In order to leave comments, you need to log in
Why doesn't output by id with Beautiful Soup?
I made such a script, but it does not output anything at all! To display a value by id.
Tell a newbie!
import requests
from bs4 import BeautifulSoup
page = requests.get("https://blockchain.info/ru/stats")
soup = BeautifulSoup(page.content, 'html.parser')
soup.select("td#market_price_usd")
Answer the question
In order to leave comments, you need to log in
All the information you need goes through the API
. You
can understand this by opening Chrome dev-tools, network tab, XHR tab. Reload the page and see this:
Looks like the data you're looking for. Go to the headers tab, there will be a link to the API (I already gave it to you above).
As a result, you don’t need to parse anything, just pull the information from the API. For good, always when you think of something from where to pull - check the site for the presence of the API.
1.select returns a list
2. to see the content of the tag, you must use the method get_text()
3. According to your link, the given cell is empty and does not contain any content
soup = BeautifulSoup(page.content, 'html.parser')
td_content = soup.select("td#market_price_usd")[0].get_text()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question