1

I have following code:

def login(self):
    print('Log in ...')

    # Open log in page and get request key
    # --------------------------------------------------------------------------------------------------------------
    login_page_url = 'https://www.footlocker.com/account/default.cfm'

    response = requests.get(login_page_url)
    request_key_pattern = re.compile('id=\"requestKey\" value=\"(\w{16})\"')
    request_key = request_key_pattern.findall(response.text)[0]
    # --------------------------------------------------------------------------------------------------------------

    # Log in
    # --------------------------------------------------------------------------------------------------------------
    login_post_url = 'https://www.footlocker.com/account/default.cfm?action=accountSignIn'

    params = {
        'requestKey': request_key,
        'co_cd': '21',
        'login_email': self.login_email,
        'login_password': self.login_password
    }

    response = requests.post(login_post_url, data=params)
    response = requests.get('https://www.footlocker.com/wishlist/default.cfm', cookies=response.cookies)

    file = open('login.html', 'w')
    file.write(response.text)

The problem is that I have successfully logged in. But when I try to access my account profile, the response shows that I still need to log in. I don't know how should I do to keep the log in session. I tried to add cookies with the request, but it didn't work.

Thank you for your help.

2
  • I can't test it now, but what about using requests' Session object?
    – TidB
    Commented Jan 4, 2017 at 9:34
  • Take a look here
    – Iron Fist
    Commented Jan 4, 2017 at 10:34

0

Browse other questions tagged or ask your own question.