Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import praw
- import json
- import requests
- import tweepy
- import time
- access_token = ['3319047260-hYs0OiGb1uvurlm0HUXIyTKKFjmJL7hIs1MfblX','3319731960-fL63tqQGoIfmMPzzSyELBMy89dcpp5IfVciiILj']
- access_token_secret = ['ehPksk8oAl7k0oMaJVm4ouzGrmSwpphb57O6cvBTjXCWr','HlCTmIMyNylBIMU3jPyvNbb0ryb3Du70WRTFbpBsgNSfG']
- consumer_key = ['rTkDstUS2cEVfo1WA9ih9uHJ5','w2NRYFX4grBVJYNULE0V0m3mL']
- consumer_secret = ['WpzXZq7s0q18rpypeWZTMfJG3zTINJkeNeGnEtLHoRL3n3Ek6L','WNWTCmUZ2AMNQp74Tbv1xsCgylPvG9v7jaVHx6XGCegv0Bj0tV']
- import MySQLdb,json,datetime
- import requests
- # configuration
- DATABASE = 'zipStreet'
- DB_SERVER = 'localhost'
- DEBUG = True
- SECRET_KEY = 'epicMedia123'
- USERNAME = 'root'
- PASSWORD = 'babamanohar'
- #Mysql Connection Declaration
- db = MySQLdb.connect(DB_SERVER,USERNAME,PASSWORD,DATABASE)
- db.autocommit(True)
- cursor = db.cursor()
- #Redis Declaration
- import redis
- redis_client = redis.StrictRedis(host='localhost', port=6379, db=0)
- def shorten(url):
- headers = {'content-type': 'application/json'}
- payload = {"longUrl": url}
- url = "https://www.googleapis.com/urlshortener/v1/url"
- r = requests.post(url, data=json.dumps(payload), headers=headers)
- link = json.loads(r.text)
- print link
- return link
- def tweeter_cities():
- auth = tweepy.OAuthHandler(consumer_key[0], consumer_secret[0])
- auth.set_access_token(access_token[0], access_token_secret[0])
- api = tweepy.API(auth)
- cursor.execute('select distinct state from zipcodes')
- states = [state[0] for state in cursor.fetchall()][1:]
- urls = []
- for state in states:
- cursor.execute('select distinct city from zipcodes where state = "%s" '%state)
- cities = [city[0] for city in cursor.fetchall()]
- for city in cities:
- urls.append(('http://zipcodestreet.net/'+state.replace(" ","-")+'/'+city.replace(" ","-"),city,state))
- for url in urls[172:]:
- api.update_status(status="Find Zipcodes Of City "+url[1]+", State "+url[2]+" : "+url[0])
- print url[0]
- time.sleep(30)
- def tweeter_zipcodes():
- auth = tweepy.OAuthHandler(consumer_key[1], consumer_secret[1])
- auth.set_access_token(access_token[1], access_token_secret[1])
- api = tweepy.API(auth)
- cursor.execute('select state,city,zipcode from zipcodes')
- urls = []
- for data in cursor.fetchall():
- state = data[0]
- city = data[1]
- zipcode = data[2]
- urls.append(('http://zipcodestreet.net/'+state.replace(" ","-")+'/'+city.replace(" ","-")+'/'+zipcode,city,state))
- for url in urls:
- api.update_status(status="ZipCodes Of City "+url[1]+", State "+url[2]+" : "+url[0])
- print url[0]
- time.sleep(30)
- if __name__ == '__main__':
- tweeter_zipcodes()
Add Comment
Please, Sign In to add comment