0

Hi I am making an app to extract stock ticker mentions from twitter. I want to know if it's possible to extract a stock ticker from a tweet, for example. My current code:

   for account in accounts:
    try:
        statuses = api.GetUserTimeline(screen_name=account)
        print(account,[s.text for s in statuses])
    except:
        continue

Results in this:

   DaleJMurray I  this too @DanielKorski
DanZanger $SPX $SPY $ES_F

If I apply print ticker as per below it fails to print the tickers, can someone kindly help

        ticker = [s.text for s in statuses.split("$")]
        print(ticker)
4

1 回答 1

0

这似乎有效

   statuses = api.GetUserTimeline(screen_name=account)
        #(account,[s.text for s in statuses])
        x=([s.text for s in statuses][0])
        #print(x)
        y=[word for word in x.split() if word[0] == "$"]
        print(y)
于 2020-05-18T14:00:47.093 回答