#๐Ÿ”’ I am try to scrap data from Yahoo Finance I can't seem to do it.

30 messages ยท Page 1 of 1 (latest)

surreal charmBOT
#

@rose rampart

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

exotic frost
#

!rule 5

surreal charmBOT
#

5. Do not provide or request help on projects that may violate terms of service, or that may be deemed inappropriate, malicious, or illegal.

rose rampart
exotic frost
#

Oh ok

#

ok so what exacly do u want to scrape from where

rose rampart
exotic frost
#

right click inspect

rose rampart
#

Copy element?

exotic frost
#

it shows where its in the html

rose rampart
#

<div class="value svelte-e2k9sg">15.581T</div>

exotic frost
#
import requests
from bs4 import BeautifulSoup

site=requests.get("https://finance.yahoo.com/sectors/technology/?guccounter=1")

html=BeautifulSoup(site.text,"html.parser")

parse the site

rose rampart
#

Ok got it

#

this is the part I have been getting confused about: tech_market_cap= soup.find('span', {'class': 'value svelte-e2k9sg'}).text

#

I'm not sure how to do it

exotic frost
#

it should be as simple as soup.find("div",_class='value svelte-e2k9sg').text

rose rampart
#

I keep getting 11 as the output when Im trying to get 15.581T

exotic frost
#

for me it gives an error bc it can find it

rose rampart
#
import requests
from bs4 import BeautifulSoup

site = requests.get("https://finance.yahoo.com/sectors/technology/?guccounter=1")

html = BeautifulSoup(site.text, "html.parser")

tech_mctotal = html.find("div", class_='value svelte-e2k9sg').text

print(tech_mctotal)

I get 11

raven gyro
#

Why not use yfinance

rose rampart
#

Im new to this Im not sure lol

#

If you could provide some code that I can learn from that would be great

exotic frost
#

ok it seems to occur 3 times

<div class="value svelte-e2k9sg">11</div>
<div class="value svelte-e2k9sg">145</div>
<div class="value svelte-e2k9sg">57.868T</div>
rose rampart
#

oh

#

How would I fix that?

exotic frost
#

do find all and get the last

#

tho that still dosent look like what we want but its the closest

rose rampart
#

Ok thanks

surreal charmBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.