def from_soup(cls, tweet):
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'],
timestamp=datetime.utcfromtimestamp(
int(tweet.find('span', '_timestamp')['data-time'])),
text=tweet.find('p', 'tweet-text').text or "",
replies = tweet.find(
'span', 'ProfileTweet-action--reply u-hiddenVisually').find(
'span', 'ProfileTweet-actionCount')['data-tweet-stat-count'] or '0',
retweets = tweet.find(
'span', 'ProfileTweet-action--retweet u-hiddenVisually').find(
'span', 'ProfileTweet-actionCount')['data-tweet-stat-count'] or '0',
likes = tweet.find(
'span', 'ProfileTweet-action--favorite u-hiddenVisually').find(
'span', 'ProfileTweet-actionCount')['data-tweet-stat-count'] or '0',
)
评论列表
文章目录