这里是链接,我要在其中通过设置商品的最大日期范围来下载csv: https://www.investing.com/commodities/gold-historical-data
如何使用Python执行此操作?我有网页,但不知道如何下载csv(
import requests
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
# Fill in your details here to be posted to the login form.
payload = {
'loginFormUser_email': 'email',
'loginForm_password': 'password'
}
proxies = {
'http': 'http://user:passw@proxy:9090',
'https': 'http://user:passw@proxy:port'
}
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36'}
# Use 'with' to ensure the session context is closed after use.
with requests.Session() as s:
r1 = s.get('https://ru.investing.com/', stream=True, verify=False, proxies=proxies, headers=headers)
print(r1.status_code) --200
r2 = s.get('https://ru.investing.com/members-admin/auth/getSignInPopUp', stream=True, verify=False, proxies=proxies, headers=headers)
print(r2.status_code) --200
# An authorised request.
r3 = s.post('https://ru.investing.com/members-admin/auth/signInByEmail/', stream=True, verify=False, proxies=proxies, headers=headers, data=payload)
print(r3.status_code) --200
r4 = s.get('https://ru.investing.com/commodities/gold-historical-data', stream=True, verify=False, proxies=proxies, headers=headers)
print(r4.status_code) -200