I would like to print the company name from the Google Finance page, using the div class appbar-snippet-primary. The code I am usng returns none or []. Wasn't able to get to the span tag containing the company name using beautifulsoup.
html = urlopen('https://www.google.com/finance?q=F')
soup = BeautifulSoup(html, "html.parser")
x = soup.find(id='appbar-snippet-primary')
print(x)
Thank you for the explanation. I have updated the code as you suggested and included the stock price, created a loop, then stored the information in a dictionary.
from bs4 import BeautifulSoup
import requests
x = ('F', 'GE', 'GOOGL')
Company = {}
for i in x:
head = {"User-Agent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36"}
html = requests.get('https://www.google.com/finance?q=%s' % (i) , headers=head).content
soup = BeautifulSoup(html, "html.parser")
c = soup.find("div", class_="appbar-snippet-primary").text
p = soup.find('span',class_='pr').span.text
Company.update({c : p})
for k, v in Company.items():
print('{:<30} {:>8}'.format(k,v))