Ejemplo n.º 1
0
def maketweet(tweetit):
    '''
    Tweet the contents of a string variable
    '''
    os.chdir(base + "repo/twitterbot/")
    import _settings as mpi  # need to cd into this directory
    t_keys = mpi.get_keys()
    auth = tweepy.OAuthHandler(t_keys['CONSUMER_KEY'],
                               t_keys['CONSUMER_SECRET'])
    auth.set_access_token(t_keys['ACCESS_KEY'], t_keys['ACCESS_SECRET'])
    api = tweepy.API(auth)
    tweet = api.update_status(tweetit)
Ejemplo n.º 2
0
from lxml import html

# ask if OSX
if os.sys.platform == 'darwin':
    base ="/Users/akeil"
else:
    base = "/home/akeil"




root = base + "/repo/twitterbot/"
os.chdir(root)
# set twitter api parameters
import _settings as mpi # need to cd into this directory
t_keys = mpi.get_keys()
api = TwitterAPI(t_keys['CONSUMER_KEY'], t_keys['CONSUMER_SECRET'], t_keys['ACCESS_KEY'], t_keys['ACCESS_SECRET'])

def process_search(searchURL):
    headers = {'user-agent': 'hivemind_bot/0.10'}
    try:
        resp = requests.get(searchURL, headers=headers)
    except: 
        print('failed at searching... oh well')
    try:    
        thePage = html.fromstring(resp.text.encode("ascii","ignore"))
    except: 
        print('failed at converting html... oh well')
    else:
        return thePage