View Single Post
Old 01-06-2012, 03:31 PM   #5
Barty
Wizard
Barty ought to be getting tired of karma fortunes by now.Barty ought to be getting tired of karma fortunes by now.Barty ought to be getting tired of karma fortunes by now.Barty ought to be getting tired of karma fortunes by now.Barty ought to be getting tired of karma fortunes by now.Barty ought to be getting tired of karma fortunes by now.Barty ought to be getting tired of karma fortunes by now.Barty ought to be getting tired of karma fortunes by now.Barty ought to be getting tired of karma fortunes by now.Barty ought to be getting tired of karma fortunes by now.Barty ought to be getting tired of karma fortunes by now.
 
Posts: 1,506
Karma: 2971549
Join Date: Sep 2010
Device: Kindle 3, PW2, iPad 3
hi, what's happening is when you submit the login it returns this

Code:
<html>
<head>
<title>Redirect to BVD</title>
</head>

<body onLoad="document.forms[0].submit();">
<form method="post" action="http://www.mwjournal.com/default.asp">
<input type="hidden" name="cust_id" value="xxxxxxxxxx">
<input type="hidden" name="status" value="xxxxxxxxxx">
<input type="hidden" name="reqURL" value="xxxxxxxxxx">
<input type="hidden" name="email" value="xxxxxxxxxx">
<input type="hidden" name="password" value="xxxxxxxxxx">
<input type="hidden" name="fname" value="xxxxxxxxxx">
<input type="hidden" name="lname" value="xxxxxxxxxx">
<input type="hidden" name="company" value="xxxxxxxxxx">
<input type="hidden" name="country" value="xxxxxxxxxx">
<input type="hidden" name="job_title" value="xxxxxxxxxx">
<input type="hidden" name="newsletter" value="xxxxxxxxxx">
<input type="hidden" name="microwave_advisor" value="xxxxxxxxxx">
<input type="hidden" name="microview" value="xxxxxxxxxx">
<input type="hidden" name="remember_me" value="xxxxxxxxxx">
<input type="hidden" name="state" value="xxxxxxxxxx">








 
<!--<include>redirect-fields.htm</include>-->
</form>
</body>
</html>
In other words, another form you need to submit. So this will do the trick

Code:
    def get_browser(self): 
        br = BasicNewsRecipe.get_browser() 
        if self.username is not None and self.password is not None: 
            br.open('http://www.omeda.com/cgi-win/mwjreg.cgi?m=login') 
            br.select_form('login') 
            br['EMAIL_ADDRESS']   = self.username 
            br['PASSWORD'] = self.password 
            html = br.submit().read()
            open('/jwtmp.html','wb').write(html)
            br.open('file:///jwtmp.html')
            br.select_form(nr=0) 
            br.submit()
        return br
I'm writing the result to a temp file, open it, then submit the form in it. I don't know if there's a more elegant way to do it without going through the temp file.

Note: you will want to clean that up for production code. You probably don't want to write to the root like that (permission problem), and you'll want to delete the temp file afterward.
Barty is offline   Reply With Quote