<commit_before>import tweepy
import requests
import re
import lxml.html
from urlparse import urlparse, parse_qs

consumer_key = "8MJXt6b7JO4D9CQuDdzNLg"
consumer_secret = "<KEY>"

access_token = "<KEY>"
access_token_secret = "<KEY>"

auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)

api = tweepy.API(auth)


def camelCaseSentenceToCase(string):
    # http://stackoverflow.com/a/9283563
    return re.sub(r'((?<=[a-z])[A-Z]|(?<!\A)[A-Z](?=[a-z]))', r' \1', string)


def twitter_trend():
    trend_list = api.trends_location('1')[0]['trends']

    for name in (dct["name"] for dct in trend_list):
        if name.startswith('#'):
            name = camelCaseSentenceToCase(name[1:])
        print name
	
def search(keyword):
    return map(
        lambda link: parse_qs(urlparse(link.get('href')).query)["du"][0],
        lxml.html.fromstring(
            requests.get("http://www.dogpile.co.uk/search/web?q=foo").text
        ).cssselect(".webResult .resultDisplayUrl")
    )<commit_msg>search now actually searches the arguments it's given rather than just 'foo'<commit_after>import tweepy
import requests
import re
import lxml.html
from urlparse import urlparse, parse_qs, urlunparse
from urllib import urlencode

consumer_key = "8MJXt6b7JO4D9CQuDdzNLg"
consumer_secret = "<KEY>"

access_token = "<KEY>"
access_token_secret = "<KEY>"

auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)

api = tweepy.API(auth)


def camelCaseSentenceToCase(string):
    # http://stackoverflow.com/a/9283563
    return re.sub(r'((?<=[a-z])[A-Z]|(?<!\A)[A-Z](?=[a-z]))', r' \1', string)


def twitter_trend():
    trend_list = api.trends_location('1')[0]['trends']

    for name in (dct["name"] for dct in trend_list):
        if name.startswith('#'):
            name = camelCaseSentenceToCase(name[1:])
        print name
	
def search(keyword):
    return map(
        lambda link: parse_qs(urlparse(link.get('href')).query)["du"][0],
        lxml.html.fromstring(
            requests.get(urlunparse(
                ("http","www.dogpile.co.uk","/search/web",'',urlencode({"q":keyword}),'')
            )).text
        ).cssselect(".webResult .resultDisplayUrl")
    )
{'fraction_non_alphanumeric': 0.15966754155730534, 'fraction_numerical': 0.014873140857392825, 'mean_word_length': 3.982570806100218, 'pattern_counts': {'":': 1, '<': 13, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3896781', 'n_tokens_mistral': 846, 'n_tokens_neox': 810, 'n_words': 148}