Compare commits
3 Commits
e09a821d69
...
4a9cbdec4e
Author | SHA1 | Date |
---|---|---|
TerenceLiu98 | 4a9cbdec4e | |
TerenceLiu98 | e4e531f93a | |
TerenceLiu98 | 1f86624b26 |
|
@ -3,9 +3,8 @@ import requests
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
|
|
||||||
url = {
|
url = {
|
||||||
"EPU-China": "https://economicpolicyuncertaintyinchina.weebly.com",
|
"EPU-China": "https://www.policyuncertainty.com/scmp_monthly.html",
|
||||||
"EPU-HKSAR": "https://economicpolicyuncertaintyinchina.weebly.com/epu-in-hong-kong.html",
|
"EPU-HKSAR": "https://www.policyuncertainty.com/hk_monthly.html",
|
||||||
"EPU-MACAUSAR": "https://economicpolicyuncertaintyinchina.weebly.com/epu-in-macao.html",
|
|
||||||
"EPU": "https://www.policyuncertainty.com/"
|
"EPU": "https://www.policyuncertainty.com/"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,20 +52,6 @@ class EPUData(object):
|
||||||
|
|
||||||
return {"data":output_data, "reference":urls_cite}
|
return {"data":output_data, "reference":urls_cite}
|
||||||
|
|
||||||
elif self.country == "MACAUSAR":
|
|
||||||
r = requests.get(url["EPU-MACAUSAR"])
|
|
||||||
webpage = html.fromstring(r.content)
|
|
||||||
urls = pd.Series(webpage.xpath("//a/@href"))
|
|
||||||
urls_data = urls[urls.str.contains("xlsx")]
|
|
||||||
urls_cite = urls[urls.str.contains("pdf")]
|
|
||||||
urls_data = [url["EPU-China"] + i for i in urls_data]
|
|
||||||
urls_cite = [url["EPU-China"] + i for i in urls_cite]
|
|
||||||
output_data = []
|
|
||||||
for i in range(0, len(urls_data)):
|
|
||||||
output_data.append(pd.read_excel(urls_data[i]))
|
|
||||||
|
|
||||||
return {"data":output_data, "reference":urls_cite}
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
r = requests.get(url["EPU"] + self.country.lower() + "_monthly.html")
|
r = requests.get(url["EPU"] + self.country.lower() + "_monthly.html")
|
||||||
webpage = html.fromstring(r.content)
|
webpage = html.fromstring(r.content)
|
||||||
|
|
Loading…
Reference in New Issue