Scrape Twitter Data in Python with Twitterscraper Module
Key Takeaways
The video demonstrates how to scrape Twitter data using the Twitterscraper Python module, allowing users to retrieve tweets without needing a Twitter API key. The module's functionality is showcased by scraping tweets related to the Notre Dame fire and transforming the data into a pandas DataFrame for further analysis.
Full Transcript
hello everyone ken here today I'm showing you how to scrape Twitter data using Python and the Twitter scraper module so on my screen is the Twitter scraper documentation it is also in the description below as you can see you can do it from the command line but I prefer to do it from the notebook it allows me to read it in directly into a data frame and allows me to manipulate it from there to get started we install it pip install Twitter Ripper I've obviously already downloaded it so all the requirements are met here now I'm going to open up spider which is my ID of choice for data science so from Twitter scraper and for query weeks now we're also going to import date/time because we want to set a date range for the tweets and we're going to import pandas because we want to turn this into a data frame after without so the first thing we're going to do is query tweets takes a couple parameters the first one and a relevant one to us is begin date is equal to so all in a query is something recent I'm gonna do the notre-dame fire that happened very recently that'll be a good example to show us something that is relevant and a lot of the information associated with that on Twitter will also an end date we're gonna do tomorrow today is the 17th for me and that's because it just takes all of yesterday's yeah well today's data as well and that's relevant if you just want to do a time window for example in one of my previous videos I did the timing around a movie premiere we can also put in a limit so let's say this is a really really popular topic we can set a limit of a thousand or so so we don't go crazy we don't have millions and millions of tweets that would take forever to download now we can also set a language so lang equals English in this case if we're doing the Notre Dame fire there's gonna be a lot of French tweets I would expect so we'd want to filter those out so it's understandable for me mainly if we wanted to just look at one person tweets we could also just query them we would set the user is equal to let's just say Rio Trump if you wanted to here is wacky comments on the Notre Dame fire you'd be able to type that in and filter specifically for that now for the real magic here we just query tweets so and we put in our parameters right here we're asking for better than fire which is our key component that we're gonna query you can also put hashtags anything relevant that you look like there we do begin date equals begin date end date equals we're gonna set the limit and so we can load all of this in and this should take just a couple minutes if you're doing anything over ten hundred thousand it can take up to you know twenty thirty minutes actually wrong the way they do this is they just have from my understanding a bunch of threads hitting Twitter so it will it depends fairly heavily on the processing power of your computer if you want to increase the speed or not so looks like we got a thousand twenty which is pretty close to our limit so I can't complain too much it it isn't super exact just because of I guess the the structure of the back end there now we want to make this relevant to us as you can see the tweets here are just in tweet objects that don't really mean it down to us yet so let's transform this into a data frame so data frame is equal to all right so after doing that we have all of our Twitter data we have the username we have the number of likes replies etc you can filter by that if you want or you can order by it etc and we also have all of the tweets as you can see there's a ton of duplicates so that's something that I like to remove duplicates of a lot of them are news related most of the URL and the actual username of the person who posted these tweets you can do a lot of really interesting stuff with this I've done the sentiment analysis in the past on Captain Marvel the movie premiere and you can see that above you can also combine it all make a word cloud related to the event or the topic that you're covering and there's plenty of other text-based analysis that you can do with this information this is a great tool it's fast easy and free and I highly recommend that you use it thank you so much for watching my video if you enjoyed it please like if you want to see more content like this please subscribe have a great one
Original Description
In this video, I show you how to scrape twitter data using the twitterscraper python module.
#DataScience #TwitterScraper #WebScraping
https://github.com/taspinar/twitterscraper
This module is great because it does not require you to get an API key from twitter. It also lets you go back beyond the 2 week paywall that twitter has.
#KenJee
⭕ Subscribe: https://www.youtube.com/c/kenjee1?sub_confirmation=1
🎙 Listen to My Podcast: https://www.youtube.com/c/KensNearestNeighborsPodcast
🕸 Check out My Website - https://kennethjee.com/
✍️Sign up for My Newsletter - https://www.kennethjee.com/newsletter
📚 Books and Products I use - https://www.amazon.com/shop/kenjee (affiliate link)
Partners & Affiliates
🌟 365 Data Science - Courses ( 57% Annual Discount): https://365datascience.pxf.io/P0jbBY
🌟 Interview Query - https://www.interviewquery.com/?ref=kenjee
MORE DATA SCIENCE CONTENT HERE:
🐤My Twitter - https://twitter.com/KenJee_DS
👔 LinkedIn - https://www.linkedin.com/in/kenjee/
📈 Kaggle - https://www.kaggle.com/kenjee
📑 Medium Articles - https://medium.com/@kenneth.b.jee
💻 Github - https://github.com/PlayingNumbers
🏀 My Sports Blog -https://www.playingnumbers.com
Check These Videos Out Next!
My Leaderboard Project: https://www.youtube.com/watch?v=myhoWUrSP7o&ab_channel=KenJee
66 Days of Data: https://www.youtube.com/watch?v=qV_AlRwhI3I&ab_channel=KenJee
How I Would Learn Data Science in 2021: https://www.youtube.com/watch?v=41Clrh6nv1s&ab_channel=KenJee
My Playlists
Data Science Beginners: https://www.youtube.com/playlist?list=PL2zq7klxX5ATMsmyRazei7ZXkP1GHt-vs
Project From Scratch: https://www.youtube.com/watch?v=MpF9HENQjDo&list=PL2zq7klxX5ASFejJj80ob9ZAnBHdz5O1t&ab_channel=KenJee
Kaggle Projects: https://www.youtube.com/playlist?list=PL2zq7klxX5AQXzNSLtc_LEKFPh2mAvHIO
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from Ken Jee · Ken Jee · 19 of 60
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
▶
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Predicting Crypto-Currency Price Using RNN lSTM & GRU
Ken Jee
Predicting Season Long NBA Wins Using Multiple Linear Regression
Ken Jee
How I Became A Data Scientist From a Business Background
Ken Jee
Should You Get A Masters in Data Science?
Ken Jee
How to Simulate NBA Games in Python
Ken Jee
Demystifying Data Science Roles
Ken Jee
The Best Way to Predict NBA Minutes Played
Ken Jee
IT'S NOT TOO LATE TO LEARN CODE!
Ken Jee
My Top 5 Data Science Resources for 2019
Ken Jee
Watch This Before Applying to Data Science Jobs
Ken Jee
Where YOU Should Start With Data Science Projects
Ken Jee
Welcome To My Channel | Ken Jee | Data Science
Ken Jee
Why You DON'T Want to be a WFH Data Scientist
Ken Jee
Was Captain Marvel Bad? A Sentiment Analysis of Twitter Data
Ken Jee
Data Science, Machine Learning, and AI: What's the Difference?
Ken Jee
Data Science: Startup vs. Large Corporation
Ken Jee
Where to Look for Data Science Jobs
Ken Jee
Work From Home Data Scientist: Day in the Life
Ken Jee
Scrape Twitter Data in Python with Twitterscraper Module
Ken Jee
Should You Learn R for Data Science?
Ken Jee
NASA Physicist Turned Data Scientist (Tim Bowling) - KNN EP. 02
Ken Jee
I Wish I Had Known THIS Before Starting in Data Science
Ken Jee
What I Learned From My Three Degrees
Ken Jee
Most Data Science Hopefuls Overlook This Important Skill
Ken Jee
Golf STATS: Strokes Gained Explained
Ken Jee
My Top 5 Data Science Internship Tips
Ken Jee
How I Got My First Data Science Internship (And How You Can Land One)
Ken Jee
Data Science: Pros and Cons
Ken Jee
Data Science Fundamentals: Data Exploration in Python (Pandas)
Ken Jee
Data Science Fundamentals: Data Manipulation in Python (Pandas)
Ken Jee
What Does a Data Scientist Actually Do?
Ken Jee
The Projects You Should Do To Get A Data Science Job
Ken Jee
Take Your Data Science Projects From Good to Great
Ken Jee
How To Get Data Science Experience (Without a Job)
Ken Jee
Data Science Fundamentals: Data Cleaning in Python
Ken Jee
Is Data Science Right For You?
Ken Jee
Thank You For The Support | What's Next | Ken Jee | Data Science
Ken Jee
How To Build A Word Cloud From Scraped Data (Python)
Ken Jee
6 Habits of Successful Data Scientists
Ken Jee
How Far Should the NBA 3-Point Line Actually Be?
Ken Jee
How to Stay Productive & Motivated When Learning Data Science
Ken Jee
Why is Balance Important in Data Science?
Ken Jee
By The Numbers: Where Should The NBA Put a 4 Point Line?
Ken Jee
Why Selling Is An Important Data Science Skill
Ken Jee
Applying Data Science To My YouTube Data: My Surprising Findings
Ken Jee
9 Ways You Can Make Extra Income as a Data Scientist
Ken Jee
Sports Analytics 101: The Pythagorean Theorem of Sports
Ken Jee
Golf: Would You Rather Be the LONGEST or STRAIGHTEST Driver on the PGA Tour?
Ken Jee
Data Science Fundamentals: Linear Regression
Ken Jee
How YOU Can Land a Sports Analytics Job
Ken Jee
The 5 Stages of Data Science Adoption
Ken Jee
Math Needed for Mastering Data Science
Ken Jee
5 Sports Analytics Books to Get You Started
Ken Jee
3 Reasons You Should NOT Become a Data Scientist
Ken Jee
Collision Course: Sports Betting + Data Science
Ken Jee
How to Scrape NBA Data Using the nba_api Python Module
Ken Jee
5 Data Science Resolutions for 2020
Ken Jee
The Data Science Interview: What to Expect
Ken Jee
The 9 Books That Changed My Perspective in 2019
Ken Jee
Questions You Should Ask Your Data Science Interviewers
Ken Jee
🎓
Tutor Explanation
DeepCamp AI