Ejemplo n.º 1
0
                        for thumb in thumbnail:
                            # print thumb['src']  #prints thumbnail url
                            urllib.urlretrieve("http:" + thumb['src'], os.path.dirname(os.path.realpath(__file__)) + '/' + board + '/' + urls[0] + '/' + thumb['src'].split(board+'/')[1])
                except:
                    pass


                try:
                    formatted_message = formatted_message.replace("//i.4cdn.org/" + board, urls[0])

                    image_urls = BeautifulSoup(formatted_message, "lxml")
                    to_replace = image_urls.find_all(re.compile("//i.4cdn.org"))
                    # print len(to_replace)
                    for loc in to_replace:
                        new_link = unicode(loc).replace('//i.4cdn.org', urls[0])
                        image_urls.replace_with(new_link)

                    # print image_urls
                    # formatted_message = str(image_urls)

                    soup = BeautifulSoup(str(image_urls), 'lxml')
                    strip_tags = soup.find('div')
                    formatted_message = str(strip_tags)
                except:
                    pass





                # for image in images: