Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7165991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:20:27+00:00 2026-05-28T14:20:27+00:00

I know long titel — I could not think of anything else ;) So

  • 0

I know long titel — I could not think of anything else 😉

So I am writing a python script which will save elements of the Twitter Search API to a csv file

writer = csv.writer(open('stocks.csv', 'a', buffering=0))
writer.writerows([(screen_name, hashtags, expanded_url , coordinates , geo , in_reply_to_user_id, followers)])

But I want to add how many followers the tweeting user has!

Now this is done via the GET users/lookup Twitter API which is limited to 350 requests per hour but allows simultaneous look up of up to 100 users

right now my script when finding a tweet looks up the users followers and pasts it with all the info of the tweet into the csv file.

This works great but after 350 searches I hit my limit!!!!

Now my question is:
Can I make the script search 100 times and store the hundred usernames somewhere and once it hits 100 it calles the GET users/lookup and inserts the info right of the search info into the excel file:

Excel example:

 [info from search ...(in many columns)] [followers of the user who sent the tweet]
 [info from search ...(in many columns)] [followers of the user who sent the tweet]
 [info from search ...(in many columns)] [followers of the user who sent the tweet]

As per request:

import urllib2
import urllib
import json
import time


 s = u'@apple OR @iphone OR @aapl OR @imac OR @ipad OR @mac OR @macbook OR macbook OR mac OR ipad OR iphone 4s OR iphone 5 OR @iphone4s OR @ iphone 5 OR aapl OR iphone'

info =  urllib2.quote(s.encode("utf8"))
page = "?q="

 openurl = urllib.urlopen("http://search.twitter.com/search.json"+ page + info)

quota = 150
user = 'twitter'
user_info = urllib.urlopen("https://api.twitter.com/1/users/lookup.json?screen_name="+user)

while quota > 10:
 openurl2 = urllib.urlopen("https://api.twitter.com/1/account/rate_limit_status.json")
 twitter_quota = openurl2.read()
 quota_json = json.loads(twitter_quota)
 quota = quota_json['remaining_hits']


 twitter_search = openurl.read()

 table_search = json.loads(twitter_search)
 print table_search

 print str(table_search[u'results'][1][u'iso_language_code'])


 lines = 0

 linesmax = len(table_search[u'results'])
 print linesmax

 while lines < linesmax:
    table_timeline_inner = table_search[u'results'][lines]


    next = table_search[u'next_page']
    lang = table_timeline_inner[u'iso_language_code']
    to = table_timeline_inner[u'to_user_name']
    text = table_timeline_inner[u'text']
    user = table_timeline_inner[u'from_user']
    geo = table_timeline_inner[u'geo']
    time = table_timeline_inner[u'created_at']
    result_type = table_timeline_inner[u'metadata'][u'result_type']
    id = table_timeline_inner[u'id']
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T14:20:28+00:00Added an answer on May 28, 2026 at 2:20 pm

    Yes. Instead of writing each row as soon as you get it, store it in a temporary set. When this set has 100 elements, look them all up using one request. Then iterate over each element of the set and write it together with the data you got from the request, which you will have to match up by userid or something.

    I’m not going to write the code for you…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to know if this web app are using long polling or anything
I know I asked a similar question to this not long ago, but I'm
I know the title is ridiculously long, but I'm in need of some assistance
Just out of interest, it would be nice to know how long my calculation
I know this might be a long shot, but here it goes. I have
I know it's safe to draw on any thread so long as I call
I would like to know a way can detect on how long the mouse
I know i can match numbers with Pattern.compile(\\d*); But it doesn't handle the long
Question: I'm interested to know the best practice for killing a long standing operation
This is a long shot, I know... Let's say I have a collection List<MyClass>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.