Simple Python scripts to do Web Scraping when I’m bored.

zScrap – dollarBlue

Unofficial Dollar Value in Argentina.


Code – (dollarBlue)

					#python3 -m pip install requests beautifulsoup4
#Lautaro Villarreal Culic'
import requests
from bs4 import BeautifulSoup
#Set URL
url = ""

if "__main__" == __name__:
    #GET method request
    page = requests.get(url)
    #Process the content
    soup = BeautifulSoup(page.content, "html.parser")

    def has_data_search(tag):
        return tag.has_attr("class")

    results = soup.find_all(has_data_search)

    for values in results:
        compra = values.find("div", attrs={"class": "value", "title": "Precio de compra del Dólar Blue en la Argentina"}).get_text()
        venta = values.find("div", attrs={"class": "value", "title": "Precio de venta del Dólar Blue en la Argentina"}).get_text()
        brecha = values.find("p", attrs={"class": "brecha"}).get_text()

        values = "${}\n${}\nBrecha: {}"
        #Format values
        values = values.format(venta, compra, brecha)
        #Show values
        #Break the for, we only want a value from each

Leave a Reply

Your email address will not be published. Required fields are marked *