Thread: Custom Cover
View Single Post
Old 12-17-2013, 05:41 AM   #11
avantman42
Wizard
avantman42 ought to be getting tired of karma fortunes by now.avantman42 ought to be getting tired of karma fortunes by now.avantman42 ought to be getting tired of karma fortunes by now.avantman42 ought to be getting tired of karma fortunes by now.avantman42 ought to be getting tired of karma fortunes by now.avantman42 ought to be getting tired of karma fortunes by now.avantman42 ought to be getting tired of karma fortunes by now.avantman42 ought to be getting tired of karma fortunes by now.avantman42 ought to be getting tired of karma fortunes by now.avantman42 ought to be getting tired of karma fortunes by now.avantman42 ought to be getting tired of karma fortunes by now.
 
avantman42's Avatar
 
Posts: 1,090
Karma: 6058305
Join Date: Sep 2010
Location: UK
Device: Kindle Paperwhite
Quote:
Originally Posted by cnfmsu View Post
Do you have an existing recipe doing this ?
I'm working on a recipe at the moment that needs to do this. Here's what I've got:

Code:
# pre-process HTML: Some links are relative. Change them to absolute
def preprocess_html(self, soup):
	for link in soup.findAll('a'):
		if link['href'].startswith('http') == False:
			# Link is relative. Make it absolute
			link['href'] = 'http://www.example.com/' + link['href']
	
	return soup
You'll need to change http://www.example.com/ to whatever URL your site uses.
avantman42 is offline   Reply With Quote