Skip to content

Instantly share code, notes, and snippets.

@eguyd
Last active August 3, 2019 01:16
Show Gist options
  • Save eguyd/77012bcf51d89801833f35283c4ddf49 to your computer and use it in GitHub Desktop.
Save eguyd/77012bcf51d89801833f35283c4ddf49 to your computer and use it in GitHub Desktop.
natural language processing algorithms to identify sentiments in market.
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)
@eguyd
Copy link
Author

eguyd commented Aug 2, 2019

typo error fixed in line 2
syntax error line 7 fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment