JustAnotherArchivist / snscrape

A social networking service scraper in Python
GNU General Public License v3.0
4.52k stars 712 forks source link

AttributeError: 'NoneType' object has no attribute 'id' #932

Closed raghdaa-ahmed closed 1 year ago

raghdaa-ahmed commented 1 year ago

I am using TwitterSearchScraper to get tweets of a user. I am getting the following error when with certain tweets that has nothing to do with my own code so I was guessing if developers of snscrape know what is going on here.

---> 14   for i, tweet in enumerate(sntwitter.TwitterSearchScraper(f"from:{username}" + conditions).get_items()):
     15 
     16     tweets.append(tweet)

[/usr/local/lib/python3.10/dist-packages/snscrape/modules/twitter.py](https://localhost:8080/#) in get_items(self)
   1693 
   1694                 for obj in self._iter_api_data('https://twitter.com/i/api/graphql/7jT5GT59P8IFjgxwqnEdQw/SearchTimeline', _TwitterAPIType.GRAPHQL, params, paginationParams, cursor = self._cursor, instructionsPath = ['data', 'search_by_raw_query', 'search_timeline', 'timeline', 'instructions']):
-> 1695                         yield from self._graphql_timeline_instructions_to_tweets(obj['data']['search_by_raw_query']['search_timeline']['timeline']['instructions'])
   1696 
   1697         @classmethod

[/usr/local/lib/python3.10/dist-packages/snscrape/modules/twitter.py](https://localhost:8080/#) in _graphql_timeline_instructions_to_tweets(self, instructions, includeConversationThreads, **kwargs)
   1489                                                         _logger.warning(f'Skipping empty tweet entry {entry["entryId"]}')
   1490                                                         continue
-> 1491                                                 yield self._graphql_timeline_tweet_item_result_to_tweet(entry['content']['itemContent']['tweet_results']['result'], tweetId = tweetId, **kwargs)
   1492                                         else:
   1493                                                 _logger.warning('Got unrecognised timeline tweet item(s)')

[/usr/local/lib/python3.10/dist-packages/snscrape/modules/twitter.py](https://localhost:8080/#) in _graphql_timeline_tweet_item_result_to_tweet(self, result, tweetId, **kwargs)
   1469                                 kwargs['quotedTweet'] = TweetRef(id = int(tweet['quoted_status_id_str']))
   1470                 if 'card' in result:
-> 1471                         kwargs['card'] = self._make_card(result['card'], _TwitterAPIType.GRAPHQL, self._get_tweet_id(tweet))
   1472                 if 'note_tweet' in result:
   1473                         kwargs['noteTweet'] = result['note_tweet']['note_tweet_results']['result']

[/usr/local/lib/python3.10/dist-packages/snscrape/modules/twitter.py](https://localhost:8080/#) in _make_card(self, card, apiType, tweetId)
   1085                                 _logger.warning(f'Unavailable user in card on tweet {tweetId}')
   1086                                 continue
-> 1087                         if user.id in userRefs:
   1088                                 if userRefs[user.id] != user:
   1089                                         _logger.warning(f'Duplicate user {user.id} with differing data in card on tweet {tweetId}')

AttributeError: 'NoneType' object has no attribute 'id'`
raghdaa-ahmed commented 1 year ago

I am very sorry for not adding appropriate labels to this issue it was just posted before I could get the chance to categorize it and I can't seem to edit this or delete the issue

JustAnotherArchivist commented 1 year ago

Closing in favour of #933, which has the proper details and a reproducer example.