I am trying to log into mailchimp at
https://login.mailchimp.com/
using this code
REQUEST_URL = "https://login.mailchimp.com"
payload = {'username': '...','password': '...'}
with requests.Session() as session:
post = session.post(REQUEST_URL, data=payload)
print(post.text)
When I display the output text in a simple html viewer I see this:
Which leads me to believe that the username is being posted correctly but the password is not. When I inspect the login webpage I see this for the password field:
It looks like I am doing everything correctly. But when I try to request a new url like, https://us12.admin.mailchimp.com/audience/ and I view the resulting html, it's still the login page. Why is it failing to log in?
EDIT... I added these lines of code:
import logging
logging.basicConfig(level=logging.DEBUG)
...
print(session.cookies.get_dict())
And this is my output:
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): login.mailchimp.com:443 DEBUG:urllib3.connectionpool:https://login.mailchimp.com:443 "POST / HTTP/1.1" 200 9948 {'PHPSESSDATA': '3fb1877dc92d79879494987b07030b36dcc1f83d%3A1560273156%3AeNoDAAAAAAE%3D', 'QA': '0', '_mcid': '1.94e032f7d29eaf0a3f717796cb7f3785', 'PHPSESSID': 'fe08be42828591d939099f0793f115aa', '_AVESTA_ENVIRONMENT': 'prod'}
EDIT 2:
I tried passing the cookies from the login like this:
with requests.Session() as session:
post = session.post(REQUEST_URL, data=payload)
r = session.get(NEXT_URL,cookies=session.cookies.get_dict())
print(r.text)
and also like this:
with requests.Session() as session:
post = session.post(REQUEST_URL, data=payload)
r = session.get(NEXT_URL,cookies=session.cookies)
print(r.text)
But neither worked. I tried getting the cookies from my browser from this area
and plugged them into a dictionary and tried using them like this:
cookys_from_browser={'MC_PLUMS_LOGIN': '...','MC_USER_INFO': '...','MC_USER_PROFILE': '...','MUID': '...',.....}
with requests.Session() as session:
post = session.post(REQUEST_URL, data=payload,cookies=cookys_from_browser)
r = session.get(NEXT_URL,cookies=cookys_from_browser)
But that also did not work.