logo

scripts

A bunch of scripts, some to be moved to their own repository git clone https://anongit.hacktivis.me/git/scripts.git/

search.py (648B)


  1. #!/usr/bin/python3
  2. # -*- encoding: utf-8 -*-
  3. from TwitterAPI import TwitterAPI, TwitterOAuth, TwitterRestPager
  4. o = TwitterOAuth.read_file('credentials.txt')
  5. api = TwitterAPI(
  6. o.consumer_key,
  7. o.consumer_secret,
  8. o.access_token_key,
  9. o.access_token_secret)
  10. def search(args):
  11. try:
  12. r = api.request('search/tweets', {'q': args[1:]})
  13. for item in r:
  14. if 'text' in item:
  15. print(item['id'], ' <\033[1m', item['user']['screen_name'], '\033[0m> — ', item['user']['name'], sep='')
  16. else:
  17. print(item)
  18. print('QUOTA: ', r.get_rest_quota())
  19. except:
  20. print(sys.exc_info())
  21. if __name__ == "__main__":
  22. import sys
  23. search(sys.argv[1:])