Re: Get the first image src from a post

2015-06-15 Thread Robert librado
very nice work On 6/15/15, Vijay Khemlani wrote: > If the description is stored as HTML I guess you could use something like > BeautifulSoup or pyquery to parse it and find the tag > > from bs4 import BeautifulSoup > > soup = BeautifulSoup(blog.description) > image_src = soup.find('img')['src'] >

Re: Get the first image src from a post

2015-06-15 Thread Vijay Khemlani
If the description is stored as HTML I guess you could use something like BeautifulSoup or pyquery to parse it and find the tag from bs4 import BeautifulSoup soup = BeautifulSoup(blog.description) image_src = soup.find('img')['src'] On Mon, Jun 15, 2015 at 8:59 AM, Robin Lery wrote: > I have

Get the first image src from a post

2015-06-15 Thread Robin Lery
I have a model to write blogs. In that I'm using a wysiwyg editor for the Blog's descritpion, through which I can insert an image within the description. class Blog(models.Model): title = models.CharField(max_length=150, blank=True) description = models.TextField() pubdate = models.Dat