0

I want to sign into www.renrendai.com using Python. The script works well with other websites but it cannot sign into this website.

I don't know why? Anyone can help me?

import requests
import sys
from bs4 import BeautifulSoup
url = 'https://www.renrendai.com/loginPage.action'
sess = requests.session()
html1 = sess.get(url).text
soup1 = BeautifulSoup(html1)
p1 = soup1.select("[name=targetUrl]")[0]["value"]
p2 = soup1.select("[name=returnUrl]")[0]["value"]
print p1
print p2
data = {
"targetUrl": p1,
"returnUrl": p2,
"j_username": "15101030402",
"j_password": "qwerty123456"
}
r = sess.post(url, data)
msg =      BeautifulSoup(sess.get('http://www.renrendai.com/lend/detailPage.action?   loanId=643702').text)
type = sys.getfilesystemencoding() 
print msg.decode("UTF-8").encode(type)
Mike Laren
  • 8,028
  • 17
  • 51
  • 70
  • 1
    Are you getting any error? – Anand S Kumar Jul 11 '15 at 04:32
  • What is in r: r = sess.post(url, data): It returned something. No error in there? – Norbert Jul 11 '15 at 04:33
  • Sorry,there is No error, I think. I want to post the data from session. I think may be there is something wrong in the format of data. But I dont know how to debug it. I am a new-hand – dongzhe tai Jul 11 '15 at 04:37
  • Sorry to bother you. Do you think there is anything wrong in the data format? I am not sure all the paramaters needed to post has been post. But I dont know how to organize it – dongzhe tai Jul 11 '15 at 04:49
  • Maybe twill would work, see http://stackoverflow.com/questions/2910221/how-can-i-login-to-a-website-with-python –  Jul 11 '15 at 05:46
  • Thank you very much,I have solve this problem. – dongzhe tai Jul 11 '15 at 11:02

0 Answers0