-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtwitter_get_urls.py
33 lines (29 loc) · 925 Bytes
/
twitter_get_urls.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env python
#kristenwidman
#Nov 20, 2012
import requests
import os
from link_shortener import create_link, create_link_2
def get_tweet_urls(query,email,date):
payload = {'q': query}
r = requests.get("http://search.twitter.com/search.json",
params=payload)
js = r.json
results = js[u'results']
i = 0
url_list = []
while i < 5:
tweet = results[i]
username = tweet['from_user']
id_str = tweet['id_str']
base_url = "https://twitter.com/"
tweet_url = os.path.join(base_url,username,'status',id_str)
created_date = tweet[u'created_at']
text = tweet[u'text']
short_url = create_link_2(tweet_url,email,date)
#print created_date, tweet_url, short_url, text,'\n'
url_list.append(short_url)
i += 1
return url_list
#if __name__ == "__main__":
#get_tweet_urls("hackerschool")