python - 如何使用 Python 通过按钮下载 csv?
问题描述
这是链接,我想通过设置商品的最大日期范围来下载 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
解决方案
推荐阅读
- firebase - 在firebase中覆盖的对象
- css - 通过css在外部单击时隐藏弹出窗口
- spring - sec:authorize 总是在浏览器中为百里香视图中的 isAuthenticated() 和 isAnonymous() 返回相同的视图
- c# - 判断两个不同的 PropertyInfo 是否来自同一个接口?
- reactjs - 将 React 应用程序导出为静态 HTML
- php - 由于编码错误,从 PHPExcel 下载文件时出错
- android - Android Jetpack Navigation Pass Lambda/Delegate 在 Fragments 之间
- java - Docker:客户端未连接到 Eureka Server
- javascript - 在 `load_node` 之后用更新的 json 数据刷新 jstree
- php - file_exists():open_basedir 限制生效。文件(/tmp/log.htm)不在允许的路径中: