From 757818474d202bc44375a853707859998950df8b Mon Sep 17 00:00:00 2001 From: JustAnotherArchivist Date: Sun, 23 Jun 2019 11:48:54 +0000 Subject: [PATCH] Add tweet ID and username fields to Tweet items --- snscrape/modules/twitter.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/snscrape/modules/twitter.py b/snscrape/modules/twitter.py index e086d6e..deb3c91 100644 --- a/snscrape/modules/twitter.py +++ b/snscrape/modules/twitter.py @@ -14,6 +14,8 @@ class Tweet(typing.NamedTuple, snscrape.base.Item): url: str date: datetime.datetime content: str + id: int + username: str outlinks: list outlinksss: str tcooutlinks: list @@ -87,7 +89,7 @@ class TwitterSearchScraper(snscrape.base.Scraper): tcooutlinks.append(div['data-card-url']) outlinks = list(dict.fromkeys(outlinks)) # Deduplicate in case the same link was shared more than once within this tweet; may change order on Python 3.6 or older tcooutlinks = list(dict.fromkeys(tcooutlinks)) - yield Tweet(url, date, content, outlinks, ' '.join(outlinks), tcooutlinks, ' '.join(tcooutlinks)) + yield Tweet(url, date, content, tweetID, username, outlinks, ' '.join(outlinks), tcooutlinks, ' '.join(tcooutlinks)) def _check_json_callback(self, r): if r.headers.get('content-type') != 'application/json;charset=utf-8':