Last active
August 3, 2019 01:16
-
-
Save eguyd/77012bcf51d89801833f35283c4ddf49 to your computer and use it in GitHub Desktop.
natural language processing algorithms to identify sentiments in market.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from bs4 import BeautifulSoup | |
import csv | |
import pandas as pd | |
mostActiveStocksUrl = "https://www.nasdaq.com/markets/most-active.aspx" | |
r = requests.get(mostActiveStocksUrl) | |
data = r.text | |
soup = BeautifulSoup(data) | |
table = soup.find_all('div', attrs = {'class': 'genTable'}) | |
all_rows = table[1].find_all('tr') | |
symbols = [] | |
names = [] | |
last_sales = [] | |
change_nets = [] | |
share_volumes = [] | |
for row in all_rows: | |
cols = row.find_all('td') | |
if len(cols): | |
names.append(cols[1].text) | |
last_sales.append(cols[2].text) | |
change_nets.append(cols[3].text) | |
share_volumes.append(cols[4].text) | |
data = pd.DataFrame( | |
{'Names': names, 'Last Sale': last_sales, 'Chnange Net': change_nets, | |
'Share Volume': share_volumes}) | |
# print(data) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
typo error fixed in line 2
syntax error line 7 fixed