def get_obras_en_cartel(session=None):
    """
    Obtiene todas las obras con sus ids
    """
    if session is None:
        session = Session()

    r = session.get(PLATEANET_URL)

    html = utils.get_unicode_from_response(r)

    soup = BeautifulSoup(html)

    obras_options = soup.select("#Obras > option")
    obras = {}
    for obra in obras_options:
        url_obra = obra.get('value')
        if url_obra is not None:
            id_obra = get_obra_id(url_obra)
            nombre_obra = obra.text
            obras[id_obra] = (nombre_obra, url_obra)

    print u"Obras en cartel: \n {obras}".format(obras=obras.keys())
    return obras
Exemple #2
0
from requests import get, utils

response = get("http://www.cbr.ru/scripts/XML_daily.asp")
encodings = utils.get_unicode_from_response(response)


def currency_rates(currency):
    content = encodings.split("<Valute ID=")
    for i in content:
        if currency in i:
            return float(
                i.replace("/", "").split("<Value>")[1].replace(",", "."))


print(currency_rates("USD"))
print(currency_rates("EUR"))
Exemple #3
0
 def _http_get(self, url, timeout=60, cache=True):
     base = requests if not cache else APP.setting("WEBCACHE")
     response = base.get(url, timeout=timeout)
     return get_unicode_from_response(response)
Exemple #4
0
from datetime import date
from requests import get, utils

response = utils.get_unicode_from_response(
    get('http://www.cbr.ru/scripts/XML_daily.asp'))


def currency_rates(code):

    content = response.split("<Valute ID=")
    for i in content:
        if code.upper() in i:
            return float(
                i.replace("/", "").split("<Value>")[-2].replace(",", "."))


print(currency_rates("USD"))
print(currency_rates("EUR"))