# ========================================================================== # @author Paul Aurbano for BBT forums # @date 2021-02 # @description check some imformation for any number of tickers provided # printint them in a data table # @use this script is provided as it, no warranties provided # @license GPL # ========================================================================== import requests import pandas as pd # urls for connections base_url = "https://finviz.com/quote.ashx?t=" # data to be retrieved from Finviz ... # you can add any tags from the main table below the chart here highlights = ["Inst Own", "Shs Float", "Short Float", "Rel Volume", "Avg Volume", "Volume", "ATR", "Price"] # basic initialization results = [] data=[] headers = {"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36"} print("Tip: use space separated ticker symbols") tickers = input("Tickers: ") for ticker in tickers.split(" "): ticker = str(ticker).upper() url = base_url + ticker print("scanning " + url) page = requests.get(url, headers=headers) df = pd.read_html(page.content, attrs={'class':'snapshot-table2'} ) df = df[0] df1 = df.iloc[:, [0,1]].set_index([0]).set_axis([ticker], axis='columns') df2 = df.iloc[:, [2,3]].set_index([2]).set_axis([ticker], axis='columns') df3 = df.iloc[:, [4,5]].set_index([4]).set_axis([ticker], axis='columns') df4 = df.iloc[:, [6,7]].set_index([6]).set_axis([ticker], axis='columns') df5 = df.iloc[:, [8,9]].set_index([8]).set_axis([ticker], axis='columns') df6 = df.iloc[:, [10,11]].set_index([10]).set_axis([ticker], axis='columns') dff = [df1, df2, df3, df4, df5, df6] for df in dff: df.index = df.index.rename('Var') data.append(pd.concat(dff).loc[highlights]) print() print(pd.concat(data, axis=1))