Пример #1
0
def getPicture(url):
    print("getting picture")

    if getProxyConfig("enable") == "1":
        # THE PROXY INFO
        proxy_uri = getProxyConfig('server')
        proxy_user = getProxyConfig('user')
        proxy_pwd = getProxyConfig('password')
        proxy_sever = 'http://'+proxy_uri
        conn = aiohttp.ProxyConnector(proxy=proxy_sever, proxy_auth=aiohttp.BasicAuth(proxy_user, proxy_pwd))
        response = yield from aiohttp.get(url, connector=conn)
    else:
        response = yield from aiohttp.get(url)
    return (yield  from  response.read())
Пример #2
0
def getCarInfo(query_car):
    print("fetching %s-%s" % (query_car['make'], query_car['mode']))

    url = "http://wwwa.autotrader.ca/cars/%s/%s/on/toronto/?prx=100&prv=Ontario&loc=Toronto" \
          % (query_car['make'],query_car['mode']) + \
          "%2c+ON&body=SUV&sts=New&showcpo=1&hprc=True&wcp=True&srt=3&rcs=0&rcp=20"
    if getProxyConfig("enable") == "1":
        # THE PROXY INFO
        proxy_uri = getProxyConfig('server')
        proxy_user = getProxyConfig('user')
        proxy_pwd = getProxyConfig('password')
        proxy_sever = 'http://'+proxy_uri
        conn = aiohttp.ProxyConnector(proxy=proxy_sever, proxy_auth=aiohttp.BasicAuth(proxy_user, proxy_pwd))
        response = yield from aiohttp.get(url, connector=conn)
    else:
        response = yield from aiohttp.get(url)
    return( yield from response.text())