10
I'm trying to build a datastore on Google App Engine to collect some stream data off of StockTwits for a bunch of companies. I'm basically replicating one I did with Twitter, but it's giving me an HTTPException: Invalid and/or missing SSL certificate error for one of the URLs. I changed the URL to look at another company, but got the same result.
Here's the code that pulls the data:
class StreamHandler(webapp2.RequestHandler):
def get(self):
tickers = ['AAPL','GOOG', 'IBM', 'BAC', 'INTC',
'DELL', 'C', 'JPM', 'WFM', 'WMT',
'AMZN', 'HOT', 'SPG', 'SWY', 'HTSI',
'DUK', 'CEG', 'XOM', 'F', 'WFC',
'CSCO', 'UAL', 'LUV', 'DAL', 'COST', 'YUM',
'TLT', 'HYG', 'JNK', 'LQD', 'MSFT',
'GE', 'LVS', 'MGM', 'TWX', 'DIS', 'CMCSA',
'TWC', 'ORCL', 'WPO', 'NYT', 'GM', 'JCP',
'LNKD', 'OPEN', 'NFLX', 'SBUX', 'GMCR',
'SPLS', 'BBY', 'BBBY', 'YHOO', 'MAR',
'L', 'LOW', 'HD', 'HOV', 'TOL', 'NVR', 'RYL',
'GIS', 'K', 'POST', 'KRFT', 'CHK', 'GGP',
'RSE', 'RWT', 'AIG', 'CB', 'BRK.A', 'CAT']
for i in set(tickers):
urlst = 'https://api.stocktwits.com/api/2/streams/symbol/'
tickerstringst = urlst + i + '.json'
tickurlst = urllib2.Request(tickerstringst)
sttweets = urllib2.urlopen(tickurlst)
stcode = sttweets.getcode()
if stcode == 200:
stresults = json.load(sttweets, 'utf-8')
if "messages" in stresults:
stentries = stresults["messages"]
for stentry in stentries:
sttweet = streamdata()
stcreated = stentry['created_at']
sttweetid = str(stentry['id'])
sttweettxt = stentry['body']
sttweet.ticker = i
sttweet.created_at = stcreated
sttweet.tweet