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
|
||||
|
||||
url = {
|
||||
"EPU-China": "https://economicpolicyuncertaintyinchina.weebly.com",
|
||||
"EPU-HKSAR": "https://economicpolicyuncertaintyinchina.weebly.com/epu-in-hong-kong.html",
|
||||
"EPU-MACAUSAR": "https://economicpolicyuncertaintyinchina.weebly.com/epu-in-macao.html",
|
||||
"EPU-China": "https://www.policyuncertainty.com/scmp_monthly.html",
|
||||
"EPU-HKSAR": "https://www.policyuncertainty.com/hk_monthly.html",
|
||||
"EPU": "https://www.policyuncertainty.com/"
|
||||
}
|
||||
|
||||
|
@ -52,20 +51,6 @@ class EPUData(object):
|
|||
output_data.append(pd.read_excel(urls_data[i]))
|
||||
|
||||
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:
|
||||
r = requests.get(url["EPU"] + self.country.lower() + "_monthly.html")
|
||||
|
|
Loading…
Reference in New Issue