Python Forum
Need to extract twitter location
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need to extract twitter location
#1
Hello everyone,

My classmate and I are doing a homework and we need help (cause we are NOT familiar at all with coding)

In brief, we're trying to extract users' location using API and isolate those from the States. (We already have a list with all locations, but we only want USA' locations from this list)

The idea is to compilate users from each states and make a graph out of it.

The problem is that we are not able to dress the list with only USA locations. Look at what we have done so far:

for le_tweet in searched_tweets:
print(le_tweet.user.location)

**the list appears**

Now we only want USA locations:

liste_localisation = le_tweet.user.location
liste_usa = ["'AL' or 'AK' or 'AZ' or 'AR' or 'CA' or 'CO' or 'CT' or 'DE' or 'FL' or 'GA' or 'HI' or 'ID' or 'IL' or 'IN' or 'IA' or 'KS' or 'KY' or 'LA' or 'ME' or 'MD' or 'MA' or 'MI' or 'MN' or 'MS' or 'MO' or 'MT' or 'NE' or 'NV' or 'NH' or 'NJ' or 'NM' or 'NY' or 'NC' or 'ND' or 'OH' or 'OK' or 'OR' or 'PA' or 'RI' or 'SC' or 'SD' or 'TN' or 'TX' or 'UT' or 'VT' or 'VA' or 'WA' or 'WV' or 'WI' or 'WY'"]

for tweet_usa in liste_localisation:
if tweet_usa == liste_usa:
print(tweet_usa)

***************************************

We are stuck here.

Can someone help 2 rookies Shy
Reply
#2
How the steps that you have shared are working? I have no idea how to do it.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020