import re
import json
import csv
from io import StringIO
from bs4 import BeautifulSoup
from selenium import webdriver


url_financials = 'https://financials.morningstar.com/ratios/r.html?t={}'
stock = 'FB'

# Yahoo finance block python request, so we use a custom User-Agent
driver = webdriver.Firefox()
driver.get(url_financials.format(stock))

soup = BeautifulSoup(driver.page_source, 'html.parser')

name = soup.find('h1').contents[0]
ticker = (soup.find('span', {'class':'gry'}).contents[0])[1:]
revenue = [None]*11

fila = 1
columna = 1
test = soup.find('tbody').contents[fila].contents[columna].contents[0]
for i in range(11):
    revenue[i] = soup.find('td',{'headers': ('Y{} i0').format(i)}).contents
#revenue1 = revenue.contents


print(name)
print(ticker)
print(test)
driver.close()
import re
import json
import csv
from io import StringIO
from bs4 import BeautifulSoup
from selenium import webdriver


url_financials = 'https://financials.morningstar.com/ratios/r.html?t={}'
stock = 'FB'

# Yahoo finance block python request, so we use a custom User-Agent
driver = webdriver.Firefox()
driver.get(url_financials.format(stock))

soup = BeautifulSoup(driver.page_source, 'html.parser')

name = soup.find('h1').contents[0]
ticker = (soup.find('span', {'class':'gry'}).contents[0])[1:]
revenue = [None]*11

fila = 1
columna = 1
test = soup.find('tbody').contents[fila].contents[columna].contents[0]
for i in range(11):
    revenue[i] = soup.find('td',{'headers': ('Y{} i0').format(i)}).contents
#revenue1 = revenue.contents


print(name)
print(ticker)
print(test)
driver.close()
# Yahoo finance block python request, so we use a custom User-Agent #revenue1 = revenue.contents