View Single Post
Old 02-09-2012, 05:24 PM   #5
kiavash
Old Linux User
kiavash began at the beginning.
 
Posts: 36
Karma: 12
Join Date: Jan 2012
Device: NST
Question ... and make it better?

Quote:
Originally Posted by kovidgoyal View Post
That should work just fine. The news download system looks for images to download after preprocess has run. Look in the log to see why the images are not downloading. Also rather than using replaceWith just set

img.name = 'img'
img['src'] = 'whatever'


After fetching all the images using the above code, they all become inline with the text. I would like to put a new line between an image and the text before/after. Tried couple of techniques including Tag(soup,'br /') and tag.insert but all ended up eliminating the image all together in the final file.

I also attached the example epub that shows the behavior I am referring to.
Spoiler:

PHP Code:
    def preprocess_html(selfsoup):
        
# Includes all the figures inside the final ebook
        # Finds all the jpg links
        
for figure in soup.findAll('a'attrs = {'href' lambda xand 'jpg' in x}):
            
            
# makes sure that the link points to the absolute web address
            
if figure['href'].startswith('/'):
                
figure['href'] = self.site figure['href']
                
            
figure.name 'img' # converts the links to img
            
figure['src'] = figure['href'# with the same address as href
            
del figure['href']
            
del figure['target']
        return 
soup 


Any idea?
Attached Files
File Type: zip mwrf.zip (1.01 MB, 269 views)

Last edited by kiavash; 02-09-2012 at 05:59 PM.
kiavash is offline   Reply With Quote