Python Forum
Tweepy: download tweets of list of followers
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Tweepy: download tweets of list of followers
#1
Hi guys, I’m currently working on a term project surrounding the analysis of Twitter followers. For that, I’m using Tweepy and a GitHub script by Fujman12 scraping information on all of the followers of one account. The output is a CSV file.

Now I’m kind of limited in my knowledge and the Tweepy documentation itself didn’t provide me any answers so there’s a couple of questions I have. It’s mostly about if it would be possible to implement what I’m trying to achieve and maybe an idea how to - I’m obviously not asking you to write an entire script for me!

a) Would it be possible to also scrape the amount of tweets the followers have at that point of time? And the date their account was created?

These are the values currently being scraped:
write_to_sheet(u.screen_name, u.followers_count, u.friends_count, u.location, u.description)
This is what the function write_to_sheet currently looks like:
def write_to_sheet(name, number_of_followers, number_following, location, description):
    global row_count

    ws1["A%d" % row_count] = name
    ws1["B%d" % row_count] = number_of_followers
    ws1["C%d" % row_count] = number_following
    ws1["D%d" % row_count] = location
    ws1["E%d" % row_count] = "https://twitter.com/%s" % name
    ws1["F%d" % row_count] = description

    wb.save("result.xlsx")
    row_count += 1
b) Is there any way for me to use Python to also scrape the tweets of the followers, meaning multiple accounts at once (not all tweets of each account, just maybe the latest 5?)? Since I will end up with a long list of followers after running my initial script, I wouldn’t be able to download the tweets of each account I’ve received one by one (there’s probably going to be more than one million names) but would there be a way to use my xlsx file as input for a script that scrapes tweets?

I feel like this text has been a mess but I hope I somehow managed to get my point across? I would also appreciate if anybody could point me into the direction of Tweepy manuals or guides beyond the documentation because simply looking at readily available GitHub scripts hasn’t taught me much about it.

Thanks!
Reply
#2
If you can see it in your browser, then yes, you can scrape it.

That said, I don't think Twitter gives all of someone's tweets, so the standard way of getting them, is to repeatedly ask for the next page of tweets until there are no more pages. Using tweepy, that looks like it might be this function: https://tweepy.readthedocs.io/en/3.7.0/a...r_timeline
Reply
#3
(Dec-05-2018, 08:13 PM)nilamo Wrote: If you can see it in your browser, then yes, you can scrape it.

That said, I don't think Twitter gives all of someone's tweets, so the standard way of getting them, is to repeatedly ask for the next page of tweets until there are no more pages. Using tweepy, that looks like it might be this function: https://tweepy.readthedocs.io/en/3.7.0/a...r_timeline


Hi! Thanks for your reply, but it's not quite what I was trying to ask! I don't want to download all of someone's tweets, I want to download a small amount of tweets (5-10 per user) from a long list of users. But I'll continue looking for a way to do that, thank you again!
Reply
#4
Take a look at that link again, it does exactly what you just explained.
Reply


Forum Jump:

User Panel Messages

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