我正在尝试创建一个自动登录到earthdata网站的脚本,因为我想从那里下载文件,但是我找不到csrf_token的正确名称。当我运行下面的脚本时,它不断给我以下错误:KeyError:" name =' authenticity_token',domain = None,path = None"
有谁知道我是如何找到正确的名字,或者我是否在这里做错了什么? 感谢
import requests
from requests import session
client = requests.Session()
url = 'https://urs.earthdata.nasa.gov/login'
USERNAME = 'my_name'
PASSWORD = 'my_pass'
client.get(url)
csrftoken = client.cookies['authenticity_token']
payload = {
'action': 'login',
'authenticity_token' : csrftoken,
'username': USERNAME,
'password': PASSWORD,
}
with session() as c:
c.post('https://urs.earthdata.nasa.gov/', data=payload)
response = c.get('https://urs.earthdata.nasa.gov/profile')
print(response.headers)
print(response.text)'