View Single Post
Old 01-03-2012, 02:36 PM   #1
kiavash
Old Linux User
kiavash began at the beginning.
 
Posts: 36
Karma: 12
Join Date: Jan 2012
Device: NST
Recipe for Microwave Journal?

Hi there,

I know it is my 1st post, but believe me I had done my homework searching/reading as many posts/pages that I could to solve it by myself unsuccessfully. Last resort is asking for help...

So I am trying to write a recipe that downloads articles from Microwave Journal website and convert it to ebook. Like NYT, MWJ also needs user/pass (which is Free, BTW). And also it has RSS site. To login, it sends you to another site and I think (not sure) that once logged in, the other site uses cookies and send the browser back to mwjournal.com. The login page has a checkbox for Remember me.

With the above foreword, I wrote the following recipe:

Spoiler:
PHP Code:
__license__   'GPL v3'

'''
mwjournal.com
'''

class MWJournal(BasicNewsRecipe):
    
title          u'Microwave Journal'
    
oldest_article 30
    max_articles_per_feed 
100
    auto_cleanup 
True
    no_stylesheets 
True
    remove_javascript 
True
    language              
'en'
    
feeds          = [(u'Current Issue'u'http://www.mwjournal.com/rss/Rss.asp?type=99')]

    
needs_subscription True

    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(nr 0)
            
br['EMAIL_ADDRESS']   = self.username
            br
['PASSWORD'] = self.password
            br
.form.find_control(name='remember_me',type="checkbox").get(nr=0).selected True
            br
.submit()
        return 
br 


I got "nr = 0" by inspecting the html file for the login page (the 1st FORM is for username/password). I also did check Remember me box (and tested unchecked too). Anyway, still when the epub is made, the site doesn't consider the user to be logged in (yes! I checked username password to be correct).

I added two attachments. ePub showing the final result (not logged in) and TXT showing ebook-convert output (I manually deleted user/password, otherwise there were there correctly).

Any help would be highly appreciated.

PS. omeda.com hosts other magazines as well which I searched recipes online repository to see if any of those magazines are already there to reuse the code, but I found none.
Attached Files
File Type: txt recipts_output.txt (14.2 KB, 80 views)
File Type: epub mwjournal.epub (106.9 KB, 49 views)

Last edited by kiavash; 01-06-2012 at 01:01 PM. Reason: Adding Attachments
kiavash is offline   Reply With Quote