Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create scraping tweets #140

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions scraping tweets
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@


# ------------------------------------------------------------------------------------
# Tutorial: How to scrape tweets in Python
# There's different packages that can be used to scrape Twitter data including tweepy, twython, twint, e.t.c
# Here we will focus on tweepy
# ------------------------------------------------------------------------------------

# First you need to create a twitter developer account to get four keys: consumer key, consumer secret, access token and access token secret

# import tweepy as step 1
# posts = api.user_timeline(screen_name = "@user", count = 7, lang ="en", tweet_mode="extended") as step 2 which is to collect tweets from a specific user account
# print("Show the 100 recent tweets: \n") as step 3 which is to print the last 100 tweets from the account
# for tweet in posts[0:100]: as step 4
# print(tweet.full_text + '\n') as step 5


# ------------------------------------------------------------------------------------
# Challenge: Print the last 10 tweets from your twitter account
# ------------------------------------------------------------------------------------