from selenium import webdriver
from urllib.request import urlopen
from bs4 import BeautifulSoup
from selenium.webdriver.chrome.options import Options

class YahooFinance:

    def __init__(self, stock_symbol):
    #    chrome_options = Options()
    #    chrome_options.add_argument("--headless")
    #    chrome_options.add_argument("--window-size=1920x1080")
    #    self.driver = webdriver.Chrome(chrome_options=chrome_options, executable_path='C:/Users/Vladio/PycharmProjects/stock_gathering/webdrivers/chromedriver.exe')
        self.base_url = ('https://finance.yahoo.com/quote/')
        self.symbol = stock_symbol

 #   def get_stock_symbol(self):
 #       self.symbol = input('Input stock symbol: ')
 #       return self.symbol

    def build_url(self):
        self.full_url = self.base_url + self.symbol
    #    self.driver.get(self.full_url)
        return self.full_url

    def parser(self):
        client_url = urlopen(self.full_url)
        self.parse_data = client_url.read()
        client_url.close()
        self.parsed_data = BeautifulSoup(self.parse_data, "html.parser")
        return self.parsed_data

    def pull_table_data(self):
        table_data = self.parsed_data.findAll("tr", {"Bxz(bb) Bdbw(1px) Bdbs(s) Bdc($c-fuji-grey-c) H(36px) "})
        volley = self.parsed_data.findAll("tr", {"Bxz(bb) Bdbw(1px) Bdbs(s) Bdc($c-fuji-grey-c) H(36px) Bdbw(0)! "})
        print(table_data[6].text.strip())
        print(volley[0].text.strip())



