Giter Club home page Giter Club logo

intro-to-programming-and-data-science's Introduction

intro-to-programming-and-data-science's People

Contributors

dependabot[bot] avatar jdfoote avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

intro-to-programming-and-data-science's Issues

Error

Dear, I have the Academic Research Access Application Approved.

I am getting errors in both codes:


  1. Error in 1 Code is as follows:

Forbidden Traceback (most recent call last)
in ()
1 hoax_tweets = []
2 for response in tweepy.Paginator(client.search_all_tweets,
----> 3 query = 'COVID'):
4 # user_fields = ['username', 'public_metrics', 'description', 'location'],
5 # tweet_fields = ['created_at', 'geo', 'public_metrics', 'text'],

3 frames
/usr/local/lib/python3.7/dist-packages/tweepy/client.py in request(self, method, route, params, json, user_auth)
122 raise Unauthorized(response)
123 if response.status_code == 403:
--> 124 raise Forbidden(response)
125 # Handle 404?
126 if response.status_code == 429:

Forbidden: 403 Forbidden


  1. Error in 2 code as follows:

403

Exception Traceback (most recent call last)
in ()
58
59
---> 60 main()

2 frames
in connect_to_endpoint(url, headers, params, next_token)
24 print(response.status_code)
25 if response.status_code != 200:
---> 26 raise Exception(response.status_code, response.text)
27 return response.json()
28

Exception: (403, '{"client_id":"23021128","detail":"When authenticating requests to the Twitter API v2 endpoints, you must use keys and tokens from a Twitter developer App that is attached to a Project. You can create a project via the developer portal.","registration_url":"https://developer.twitter.com/en/docs/projects/overview","title":"Client Forbidden","required_enrollment":"Standard Basic","reason":"client-not-enrolled","type":"https://api.twitter.com/2/problems/client-forbidden"}')

Any suggestion, please?

Add place info error

Dear Foote,
I try to associate the place info with the tweet, just like the user info. But I get an error.
The sections I made changes and the line I got an error on are as follows. Thanks a lot.

client = tweepy.Client(bearer_token, wait_on_rate_limit=True) hoax_tweets = [] for response in tweepy.Paginator(client.search_all_tweets, query = 'deprem lang:tr', user_fields = ['id', 'name', 'username', 'public_metrics', 'description', 'location', 'verified'], tweet_fields = ['id', 'created_at', 'geo', 'public_metrics', 'text'], place_fields = ['full_name','place_type'], expansions = ['author_id', 'geo.place_id'], start_time = '2023-01-14T00:00:00Z', end_time = '2023-01-15T00:00:00Z', max_results=500): time.sleep(1) hoax_tweets.append(response)

`result = []
user_dict = {}
place_dict = {}

for response in hoax_tweets:
# Take all of the users, and put them into a dictionary of dictionaries with the info we want to keep
for user in response.includes['users']:
user_dict[user.id] = {'username': user.username,
'name': user.name,
'followers': user.public_metrics['followers_count'],
'tweets': user.public_metrics['tweet_count'],
'description': user.description,
'location': user.location,
'verified': user.verified
}

for place in response.includes['places']:
    place_dict[place.id] = {'full_name': place.full_name,
                            'place_type': place.place_type
                            }
      
for tweet in response.data:
    # For each tweet, find the author's information
    author_info = user_dict[tweet.author_id]
    # For each tweet, find the places information
    place_info = place_dict[tweet.place_id]  #**Error Line**
                            
                               
    # Put all of the information we want to keep in a single dictionary for each tweet
    result.append({'author_id': tweet.author_id, 
                   'username': author_info['username'],
                   'author_followers': author_info['followers'],
                   'author_tweets': author_info['tweets'],
                   'author_description': author_info['description'],
                   'author_location': author_info['location'],
                   'text': tweet.text,
                   'created_at': tweet.created_at,
                   'retweets': tweet.public_metrics['retweet_count'],
                   'replies': tweet.public_metrics['reply_count'],
                   'likes': tweet.public_metrics['like_count'],
                   'quote_count': tweet.public_metrics['quote_count'],
                   'tweet_id': tweet.id,
                   'author_name': author_info['name'],
                   'verified': author_info['verified'],
                   'full_name': place_info['full_name'],
                   'place_type': place_info['place_type']
                  })`

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.