-
Notifications
You must be signed in to change notification settings - Fork 576
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add tracking of mentions to tweets #98
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,27 +17,34 @@ def __init__(self, user, fullname, id, url, timestamp, text, replies, retweets, | |
self.retweets = retweets | ||
self.likes = likes | ||
self.html = html | ||
self.mentions = mentions | ||
|
||
@classmethod | ||
def from_soup(cls, tweet): | ||
mentions = [] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks a bit cumbersome. |
||
try: | ||
mentions = tweet.find('div', 'tweet')['data-mentions'].split() | ||
except e: | ||
pass | ||
return cls( | ||
user=tweet.find('span', 'username').text[1:], | ||
fullname=tweet.find('strong', 'fullname').text, | ||
id=tweet['data-item-id'], | ||
url = tweet.find('div', 'tweet')['data-permalink-path'], | ||
url=tweet.find('div', 'tweet')['data-permalink-path'], | ||
timestamp=datetime.utcfromtimestamp( | ||
int(tweet.find('span', '_timestamp')['data-time'])), | ||
text=tweet.find('p', 'tweet-text').text or "", | ||
replies = tweet.find( | ||
replies=tweet.find( | ||
'span', 'ProfileTweet-action--reply u-hiddenVisually').find( | ||
'span', 'ProfileTweet-actionCount')['data-tweet-stat-count'] or '0', | ||
retweets = tweet.find( | ||
retweets=tweet.find( | ||
'span', 'ProfileTweet-action--retweet u-hiddenVisually').find( | ||
'span', 'ProfileTweet-actionCount')['data-tweet-stat-count'] or '0', | ||
likes = tweet.find( | ||
likes=tweet.find( | ||
'span', 'ProfileTweet-action--favorite u-hiddenVisually').find( | ||
'span', 'ProfileTweet-actionCount')['data-tweet-stat-count'] or '0', | ||
html=str(tweet.find('p', 'tweet-text')) or "", | ||
mentions=mentions, | ||
) | ||
|
||
@classmethod | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are never passing the contents of 'mentions' in the from_soup method to this class. (see line 9)