我正在尝试使用python从https://www.myfxbook.com/forex-economic-calendar下载经济日历。我可以手动做到这一点,但想自动化它。我也试过卷曲,但似乎缺少了一些东西。我也试过下载xml格式的数据,但也不能让它工作。
import requests
from requests.auth import HTTPBasicAuth, HTTPDigestAuth
url = 'https://www.myfxbook.com/calendar_statement.csv?filter=0-1-2-3_AUD-CAD-CHF-CNY-EUR-GBP-JPY-NZD-USD&end=2022-07-13%2022:59:59.059&start=2022-07-11%2023:00:00.0&calPeriod=10&tabType=0'
response = requests.get(url, verify=False, allow_redirects=True, auth=HTTPDigestAuth('user', 'password'))
print(response)
print(response.content)
print(response.text)
print(response.status_code)
print(response.headers['content-type'])
您可以使用以下代码:
import requests
URL = "https://www.myfxbook.com/calendar_statement.csv?filter=0-1-2-3_AUD-CAD-CHF-CNY-EUR-GBP-JPY-NZD-USD&end=2022-07-13%2022:59:59.059&start=2022-07-11%2023:00:00.0&calPeriod=10&tabType=0"
response = requests.get(URL)
open("calendar_statement.csv", "wb").write(response.content)