i would like to extract some comments(p tags) from the following link :
AAPL
i searched class info from the inspect menu and found following important info about div and p tags:
for the div we have : Mstart(40px) Fz(14px) Pos(r) something like this
for the p we have : C($tertiaryColor) Fz(12px) Mb(6px)
so based on following stackoverflow help : help i wrote following code :
import requests
from bs4 import BeautifulSoup
import re
def get_url(ticker):
url = f'https://finance.yahoo.com/quote/{ticker}?p={ticker}&.tsrc=fin-srch'
response = requests.get(url)
soup = BeautifulSoup(response.text, 'html.parser')
# print(soup)
# regex = re.compile('.*Mb(6px)')
for each_tag in soup.select('div[class*="Pos(r)"]'):
print(each_tag.get_text())
# regex = re.compile('.*Mb(6px).*')
# for EachPart in soup.find_all("p", {"class": regex}):
# print(EachPart.get_text())
text ='AAPL'
get_url(text)
but it returns nothing, is there any error in my code? please help me