I'm trying to programmably access a website
from robobrowser import RoboBrowser
import sys
browser = RoboBrowser(history=True)
browser.open('https://test.com/login')
loginForm = browser.get_form()
loginForm['UserName']='username'
loginForm['Password']='*'
browser.submit_form(loginForm)
if browser.response.ok:
if browser.response.content[2]=='false':
print browser.response.content[4]
sys.exit(1)
website returned json format ( at least i think it's json), but i can't seems to find robobrowser api for dealing with json.
{"RedirectUrl":null,"IsSuccess":false,"Message":null,"CustomMessage":null,"Errors":[{"Key":"CaptchaValue","Value":["Your response did not match. Please try again."]}],"Messages":{},"HasView":true.......}
As you can see I want to test if "isSuccess", and print error message, how can I proceed in this case?
thanks
found a solution using json
json.load(StringIO(browser.response.content))