title: Python - Beautifulsoup to PDF with picture (relative paths)
body: <p>I use mechanize for browse a website. After this, I use beautifulsoup for manipulatting the content of a webpage (convert to unicode, remove some lines). Now I want to create of PDF file from the html source obtain with Beautifulsoup. Iuse pdfkit and it works fine for the text. But now I want to create also pdf with pictures which are in the html code. The url are specified (also for pictures) by using a relative path '../../' etc. </p>
  
  <p>How can I change all the url for considering absolute paths and how can I obtain the pictures in the pdf files? Will be the change of the path sufficient for obtaining the pictures?</p>
  
  <p><strong>SOLUTION:</strong> (based on dudu1791 proposal)</p>
  
  <pre><code>#changement liens vers images
  def ChangeLinkIMG(soup,baseurl):
      #parcours des images
      for imgLK in soup.findAll('img'):    
          #chemin relatif image
          try:
              relaIMG=imgLK['src'] 
              #creation lien absolu
              absoIMG=urljoin(baseurl,relaIMG)
              imgLK['src']=absoIMG
              print absoIMG
          except:
              pass
      return soup
  </code></pre>