Пример #1
0
def get_currency():
    url_real = "http://www.google.com/finance/converter?a=1&from=EUR&to=BRL"
    url_dollar = "http://www.google.com/finance/converter?a=1&from=EUR&to=USD"

    ##################################################
    ##################REAL##########################
    ##################################################
    real_html = httpUtils.fetchURL(url_real)

    soup_real = BeautifulSoup(real_html)

    t = str(soup_real.body.find(id="currency_converter_result"))

    notags = html_to_info.remove_html_tags(t)

    start = notags.find("1 EUR = ")
    end = notags.find("BRL")

    str_real = notags[start + 7:end]

    real = float(str_real.strip())

    ##################################################
    ##################DOLLAR##########################
    ##################################################

    dollar_html = httpUtils.fetchURL(url_dollar)

    soup_dollar = BeautifulSoup(dollar_html)

    t = str(soup_dollar.body.find(id="currency_converter_result"))

    notags = html_to_info.remove_html_tags(t)

    start = notags.find("1 EUR = ")
    end = notags.find("USD")

    str_dollar = notags[start + 7:end]

    dollar = float(str_dollar.strip())

    conversoes = db.GqlQuery("SELECT * " "FROM Conversoes ")

    for conversao in conversoes:
        conversao.delete()

    #TO ADD TO DATABASE
    add_info_conversoes(real, dollar)
Пример #2
0
def get_currency():
    url_real = "http://www.google.com/finance/converter?a=1&from=EUR&to=BRL"
    url_dollar = "http://www.google.com/finance/converter?a=1&from=EUR&to=USD"

    ##################################################
    ##################REAL##########################
    ##################################################
    real_html = httpUtils.fetchURL(url_real)

    soup_real = BeautifulSoup(real_html)

    t = str(soup_real.body.find(id="currency_converter_result"))

    notags = html_to_info.remove_html_tags(t)

    start = notags.find("1 EUR = ")
    end = notags.find("BRL")

    str_real = notags[start + 7 : end]

    real = float(str_real.strip())

    ##################################################
    ##################DOLLAR##########################
    ##################################################

    dollar_html = httpUtils.fetchURL(url_dollar)

    soup_dollar = BeautifulSoup(dollar_html)

    t = str(soup_dollar.body.find(id="currency_converter_result"))

    notags = html_to_info.remove_html_tags(t)

    start = notags.find("1 EUR = ")
    end = notags.find("USD")

    str_dollar = notags[start + 7 : end]

    dollar = float(str_dollar.strip())

    conversoes = db.GqlQuery("SELECT * " "FROM Conversoes ")

    for conversao in conversoes:
        conversao.delete()

        # TO ADD TO DATABASE
    add_info_conversoes(real, dollar)
Пример #3
0
def pablo_aimar(url,moeda):

	cards = None
	
	html = httpUtils.synch_fetchURL(url)
	
	if html == 502:
		html = httpUtils.fetchURL(url)
		#Must break if unavailable
		if html == 502:
			if "cardsmagic" in url:
				error_cards = []
				error_cards.append(cartaMagic("N/A","N/A","N/A","N/A","N/A","Cardsmagic - Site Unavailable"))
				return info_to_table(error_cards)

	
	if "cardsmagic" in url:
		info = cardsmagicHTMLtoInfo(html)
		if info == "No info":
			error_cards = []
			error_cards.append(cartaMagic("N/A","N/A","N/A","N/A","N/A","Cardsmagic"))
			cards = info_to_table(error_cards)
		else:
			cards = info_to_table(info,"Euro",moeda)

	return cards