How to get the image src data through beautifulsoup?
<p>I want to get the image src data of all <code>coming soon</code> movies from this link:-
<a href="http://www.fandango.com/moviescomingsoon?GenreFilter=Drama" rel="nofollow">Fandango.com</a> </p>

<p>This is the code:-</p>

<pre><code>def poster(genre):
      poster_link = []
      request = requests.get(http://www.fandango.com/moviescomingsoon?GenreFilter=genre)
      content = request.content
      soup = BeautifulSoup(content, "html.parser")
      soup2 = soup.find('div', {'class':'movie-ls-group'})
      elements = soup2.find_all('img')

      for element in elements:
          poster_link.append(element.get('src'))

      return poster_link
</code></pre>

<p>When I'm printing the poster_link array then it's giving me <code>None</code> instead of image source.</p>

<p>Try this.  It shortcuts the subsetting and grabs all of the images that have the proper class.</p>

<pre><code>def poster(genre):
    poster_link = []
    request = requests.get('http://www.fandango.com/moviescomingsoon?GenreFilter=%s' %genre)
    content = request.content
    soup = BeautifulSoup(content, "html.parser")
    imgs = soup.find_all('img', {'class': 'visual-thumb'})

    for img in imgs:
        poster_link.append(img.get('data-src'))
    return poster_link
</code></pre>

python beautifulsoup