View Single Post
Old 07-23-2014, 01:47 PM   #1
Steven630
Groupie
Steven630 began at the beginning.
 
Posts: 180
Karma: 10
Join Date: May 2012
Device: Kindle Paperwhite2
Need Help with Login

How should I write a recipe to log into the following page:
https://membership.chosun.com/login/index_n.jsp

Is this right? I tried, but it doesn't seem to work.

Code:
    def get_browser(self):
        br = BasicNewsRecipe.get_browser(self)
        if self.username is not None and self.password is not None:
            cookies = mechanize.CookieJar()
            br = mechanize.build_opener(mechanize.HTTPCookieProcessor(cookies))
            request = urllib.urlencode([('USER', self.username), ('PASSWORD', self.password),])
            response = br.open('https://membership.chosun.com/login/index_n.jsp', request)
        return br
I've also tried the code below. Still not working. Articles that don't require login download well. But premium articles that needs login are left out.

Code:
    def get_browser(self):
        br = BasicNewsRecipe.get_browser(self)
        if self.username is not None and self.password is not None:
            br.open('http://membership.chosun.com/login/index_n.jsp')
            br.select_form(name='dizzologinform')
            br['USER']   = self.username
            br['PASSWORD'] = self.password
            br.submit()
        return br

Last edited by Steven630; 07-23-2014 at 01:57 PM.
Steven630 is offline   Reply With Quote