forked from soumilshah1995/hacking-API-from-website-Python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGoldRate.py
More file actions
20 lines (15 loc) · 638 Bytes
/
Copy pathGoldRate.py
File metadata and controls
20 lines (15 loc) · 638 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import requests
__author__ = "soumil nitin shah "
headers = {
'Accept-Encoding': 'gzip, deflate, sdch',
'Accept-Language': 'en-US,en;q=0.8',
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
'Referer': 'http://www.wikipedia.org/',
'Connection': 'keep-alive',
}
url = " https://data-asg.goldprice.org/dbXRates/USD"
r = requests.get(url=url, headers=headers)
data = r.json()
gold_price = data["items"][0]["xauPrice"]
print(gold_price)