Ejemplo n.º 1
0
def html_status(**kargs):
    """ Retrieve the tweets specified by id and username by web access"""
    tid = kargs['id']
    uname = kargs['screen_name']
    host = 'twitter.com'
    path = '%s/status/%d' % (uname, tid)
    html = api_call2(host, path, False).read().decode('utf-8', errors='ignore')
    status = htmlstatus2dict(html)
    status['id'] = kargs['id']
    status['screen_name'] = kargs['screen_name']
    return status
Ejemplo n.º 2
0
def html_status(**kargs):
    """ Retrieve the tweets specified by id and username by web access"""
    tid = kargs['id']
    uname = kargs['screen_name']
    host = 'twitter.com'
    path = '%s/status/%d' % (uname, tid)
    html = api_call2(host, path, False).read().decode('utf-8', errors='ignore')
    status = htmlstatus2dict(html)
    status['id'] = kargs['id']
    status['screen_name'] = kargs['screen_name']
    return status
Ejemplo n.º 3
0
def searchrequest(**kargs):
    """Bing's search API
    """
    host = 'api.bing.net'
    #host = 'api.search.live.net'
    api_path = 'json.aspx'
    kargs['Web.Count'] = 50
    kargs['Web.Offset'] = 0
    path = buildpath(api_path, kargs)
    sresults = list()
    while True:
        try:
            time.sleep(1)
            resp = api_call2(host, path, False)
            jresp = json.loads(resp.read())
            sresults.extend(jresp['SearchResponse']['Web']['Results'])
            break
        except APIError as err:
            traceback.print_exc(file=sys.stdout)
            print err.code
            print err.resp.read()
    return sresults