Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
config.py
__pycache__
10 changes: 6 additions & 4 deletions options.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
from bs4 import BeautifulSoup
import urllib.request
from config import API_KEY
from alpha_vantage.timeseries import TimeSeries
import json
import datetime
import requests

def getEarningsHistoryHTML(stock):
fp = urllib.request.urlopen("https://www.nasdaq.com/earnings/report/{}".format(stock))
byteArr = fp.read()
headers = {'User-Agent': 'Mozilla/5.0'}
s = "https://www.nasdaq.com/market-activity/stocks/{}/earnings".format(stock)
fp = requests.get(s, headers=headers)
byteArr = fp.content
html = byteArr.decode("utf8")
fp.close()
return html

def getDate(quarterReport):
Expand All @@ -19,6 +20,7 @@ def getPastEarningsDates(stock):
pastEarningsDates = []
soup = BeautifulSoup(getEarningsHistoryHTML(stock), 'html.parser')
table = soup.table.find_all('tr')
print(table)
for i in range(1, len(table)):
quarterReport = table[i]
date = getDate(quarterReport)
Expand Down