mirror of
https://github.com/bellingcat/snscrape.git
synced 2026-06-13 04:48:28 +03:00
Merge pull request #615 from engkimo/fix-return-twitter-place-ids
Add returning Twitter Place IDs
This commit is contained in:
@@ -139,6 +139,7 @@ class Coordinates:
|
|||||||
|
|
||||||
@dataclasses.dataclass
|
@dataclasses.dataclass
|
||||||
class Place:
|
class Place:
|
||||||
|
id: str
|
||||||
fullName: str
|
fullName: str
|
||||||
name: str
|
name: str
|
||||||
type: str
|
type: str
|
||||||
@@ -891,7 +892,7 @@ class _TwitterAPIScraper(snscrape.base.Scraper):
|
|||||||
if (coords := tweet['geo']['coordinates']) and len(coords) == 2:
|
if (coords := tweet['geo']['coordinates']) and len(coords) == 2:
|
||||||
kwargs['coordinates'] = Coordinates(coords[1], coords[0])
|
kwargs['coordinates'] = Coordinates(coords[1], coords[0])
|
||||||
if tweet.get('place'):
|
if tweet.get('place'):
|
||||||
kwargs['place'] = Place(tweet['place']['full_name'], tweet['place']['name'], tweet['place']['place_type'], tweet['place']['country'], tweet['place']['country_code'])
|
kwargs['place'] = Place(tweet['place']['id'], tweet['place']['full_name'], tweet['place']['name'], tweet['place']['place_type'], tweet['place']['country'], tweet['place']['country_code'])
|
||||||
if 'coordinates' not in kwargs and tweet['place'].get('bounding_box') and (coords := tweet['place']['bounding_box']['coordinates']) and coords[0] and len(coords[0][0]) == 2:
|
if 'coordinates' not in kwargs and tweet['place'].get('bounding_box') and (coords := tweet['place']['bounding_box']['coordinates']) and coords[0] and len(coords[0][0]) == 2:
|
||||||
# Take the first (longitude, latitude) couple of the "place square"
|
# Take the first (longitude, latitude) couple of the "place square"
|
||||||
kwargs['coordinates'] = Coordinates(coords[0][0][0], coords[0][0][1])
|
kwargs['coordinates'] = Coordinates(coords[0][0][0], coords[0][0][1])
|
||||||
|
|||||||
Reference in New Issue
Block a user