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

class StockTwits:

    def __init__(self, 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://stocktwits.com/symbol/')
        self.symbol = symbol

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


    def open_parser(self):
        client_url = urlopen(self.base_url + self.symbol)
        self.parse_data = client_url.read()
        client_url.close()
        self.parsed_data = BeautifulSoup(self.parse_data, "html.parser")
        return self.parse_data

    def find_element(self):
        self.watchers = self.parsed_data.find("div", {"StockHeader__watchers___HebiD"})
        return self.watchers

    def display(self):
        print(self.watchers.text.strip())



