'How do I extract a text from a website(html)

I'm trying to get the value (38.08%) from the yahoo finance.

What I have so far is this:

headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.3'}
reg_url = 'https://finance.yahoo.com/quote/DIS/analysis?p=DIS'
req = Request(url=reg_url, headers=headers) 
soup = BeautifulSoup(requests.get(reg_url,headers=headers).content,'html.parser')

https://finance.yahoo.com/quote/DIS/analysis?p=DIS

location of the required value

Thanks in advance



Solution 1:[1]

To extract the html for the text you want to

  1. Highlight the text you want to copy by clicking and dragging with your mouse
  2. right click on the highlighted text
  3. Click inspect on the menu that comes up

this is what it should look like

https://i.stack.imgur.com/CI1ga.png

Hopefully this helps you

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Lsteryoshi