-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathusd_nis.py
More file actions
49 lines (28 loc) · 825 Bytes
/
usd_nis.py
File metadata and controls
49 lines (28 loc) · 825 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
__author__ = 'davesave'
import requests
from bs4 import BeautifulSoup
def num(s):
try:
return int(s)
except ValueError:
try:
return float(s)
except ValueError:
return ""
def get_blomberg_currency(full_url):
r = requests.get(full_url)
soup = BeautifulSoup(r.content)
tag = soup.select(".price")[0]
t = tag.text.replace(" ", "")
currency=""
for ttt in t.split("\n"):
if ttt == "\n":
continue
if num(ttt)!='':
currency = num(ttt)
return str(currency)
url = "http://www.bloomberg.com/quote/"
end = "USDILS:CUR"
print ("Got Currency " + get_blomberg_currency(url+end) + " for " + end )
def test_dave():
assert get_blomberg_currency("http://www.bloomberg.com/quote/USDILS:CUR") > 0