使用 Python3 登录表单。无法使用 python-requests

Login into a Form using Python3. Not able to do it with python-requests

此页面的登录表单不久前已更改,之前我可以登录,但现在无法登录。有问题的页面是:http://www.racingpost.com/ and the one i think holds the new login form is https://reg.racingpost.com/mpp/sign_in.sd

我认为部分登录是在外部完成的,并且可能会在问题出现时出现。我试过使用 python 请求并传入 headers 参数,但我无法克服它。

我不是 html 方面的专家,因此传递给请求的参数可能不正确。有人可以帮助我吗?

此致, 阿尔伯特.

我发现唯一的方法是使用 selenium,这对我来说并不理想,因为我想直接在代码上进行,但无论如何都可以通过以下方式完成:

driver = self.driver
# Uncoment to enable login
driver.get( "https://reg.racingpost.com/mpp/sign_in.sd" )
driver.find_element_by_id( "input-email").clear()
driver.find_element_by_id( "input-email").send_keys("email@address.com" )
driver.find_element_by_id( "input-pwd").clear()
driver.find_element_by_id( "input-pwd").send_keys("passw0rd" )
driver.find_element_by_id( "button-sign-in").click()
time.sleep(8)
driver.get('http://www.racingpost.com/horses2/cards/card.sd?race_id=636248&r_date=2015-10-28#raceTabs=sc_' )
#time.sleep(10)
driver.execute_script( "window.stop()")
print(driver.page_source.encode( 'utf-8'))