View Single Post
Old 01-06-2012, 09:43 PM   #6
kiavash
Old Linux User
kiavash began at the beginning.
 
Posts: 36
Karma: 12
Join Date: Jan 2012
Device: NST
Hi Barty,

Thanks a lot. This explains everything. A big step forward thanks to your help.

I am going to study ESPN recipe closely. Kovid used "TemporaryFile" to eliminate writing to the root (or any folder that may not have permission). Hopefully "TemporaryFile" or "PersistentTemporaryFile" (example) will be the magic bullet.

PHP Code:
from calibre.ptempfile import TemporaryFile
...
    
def get_browser(self):
        
br BasicNewsRecipe.get_browser()
        
br.set_handle_refresh(False)
        
url = ('https://r.espn.go.com/members/v3_1/login')
        
raw br.open(url).read()
        
raw re.sub(r'(?s)<form>.*?id="regsigninbtn".*?</form>'''raw)
        
with TemporaryFile(suffix='.htm') as fname:
            
with open(fname'wb') as f:
                
f.write(raw)
            
br.open_local_file(fname)

        
br.form br.forms().next()
        
br.form.find_control(name='username'type='text').value self.username
        br
.form['password'] = self.password
        br
.submit().read()
        
br.open('http://espn.go.com').read()
        
br.set_handle_refresh(True)
        return 
br 
kiavash is offline   Reply With Quote