Skip to content

Commit

Permalink
+curs valutar
Browse files Browse the repository at this point in the history
  • Loading branch information
pax committed Sep 5, 2023
1 parent 8e51f78 commit 02352a0
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 1 deletion.
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,34 @@ uses [*Git scraping*: track changes over time by scraping to a Git repository](h

[flatgithub.com/gov2-ro/prometeu](https://flatgithub.com/gov2-ro/prometeu) (Flat Data viewer)

---

## Scrapers

### [Situația drumurilor](data/andnet/)

circulatie ingreunata, circulatie intrerupta, evenimente rutiere, lucrari, meteo, starea generala, temperatura, situatia-drumurilor-paths, situatia-drumurilor-points | sursă: [dispecerat.andnet.ro](https://dispecerat.andnet.ro/)

### [Timp așteptare vame](data/politia-de-frontiera)
---

### [Timp așteptare puncte frontieră](data/politia-de-frontiera)

sursă: [politiadefrontiera.ro](https://www.politiadefrontiera.ro/ro/traficonline)

---

### [posturi.gov.ro](data/posturi/)

Posturile vacante din cadrul autorităților și instituțiilor publice din România publicate | sursă: [posturi.gov.ro](http://posturi.gov.ro/)

---

### [Stare sistem termoficare oraș Bucuresti](data/cmteb/)

sursă: [cmteb.ro](https://www.cmteb.ro/harta_stare_sistem_termoficare_bucuresti.php)

---

### Curs valutar

sursă: [bnr.ro](https://www.bnr.ro/nbrfxrates.xml)
40 changes: 40 additions & 0 deletions curs-valutar.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import requests
import xml.etree.ElementTree as ET
import csv

outfile = 'data/financiar/curs-valutar.csv'

# Define the URL of the XML data
xml_url = 'https://www.bnr.ro/nbrfxrates.xml'

# Send a GET request to the URL and get the response
response = requests.get(xml_url)

# Check if the request was successful
if response.status_code == 200:
# Parse the XML content with namespace
xml_data = response.content
root = ET.fromstring(xml_data)

# Define the namespace
ns = {'ns': 'http://www.bnr.ro/xsd'}

# Extract data from the XML
date = root.find(".//ns:Cube", namespaces=ns).attrib['date']
rates = root.findall(".//ns:Rate", namespaces=ns)

# Create a CSV file and write header
csv_filename = outfile
with open(csv_filename, mode='w', newline='') as csv_file:
csv_writer = csv.writer(csv_file)
csv_writer.writerow(["Currency", "Rate"])

# Write exchange rates to CSV
for rate in rates:
currency = rate.attrib['currency']
rate_value = rate.text
csv_writer.writerow([currency, rate_value])

print(f"Exchange rates saved to {csv_filename}")
else:
print("Failed to fetch XML data")
32 changes: 32 additions & 0 deletions data/financiar/curs-valutar.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
Currency,Rate
AED,1.2531
AUD,2.9370
BGN,2.5304
BRL,0.9321
CAD,3.3719
CHF,5.1858
CNY,0.6302
CZK,0.2050
DKK,0.6640
EGP,0.1489
EUR,4.9491
GBP,5.7800
HUF,1.2855
INR,0.0555
JPY,3.1285
KRW,0.3449
MDL,0.2566
MXN,0.2673
NOK,0.4294
NZD,2.7063
PLN,1.1040
RSD,0.0422
RUB,0.0472
SEK,0.4157
THB,0.1298
TRY,0.1719
UAH,0.1246
USD,4.6025
XAU,285.7467
XDR,6.0918
ZAR,0.2403

0 comments on commit 02352a0

Please sign in to comment.