Compare commits

..

3 Commits

Author SHA1 Message Date
TerenceLiu98 4a9cbdec4e update EPU 2023-04-20 20:39:50 +08:00
TerenceLiu98 e4e531f93a update EPU 2023-04-20 20:28:04 +08:00
TerenceLiu98 1f86624b26 update EPU 2023-04-20 20:24:33 +08:00
1 changed files with 2 additions and 17 deletions

View File

@ -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/"
} }
@ -52,20 +51,6 @@ class EPUData(object):
output_data.append(pd.read_excel(urls_data[i])) output_data.append(pd.read_excel(urls_data[i]))
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")