1

I have this script to extract image URLs from Bing. When I run the script on my computer, the script always return the URL of the first image of the page.

However, my API runs on Heroku and whenever I make a request, for some reason the API returns wrong url, could be the 3rd, 11th image URL etc., even though the script is identical to the one I have locally.

This is the script:

from robobrowser import RoboBrowser
import re

def getImage(artist):
    url = "https://www.bing.com/images/search?q=" + artist + "&go=S%C3%B6k&qs=ds&form=QBIR&scope=images"

    br = RoboBrowser()

    br.open(url)

    html = str(br.parsed)

    result = re.search(r'http([^\'" >]+)jpg', html).group(0)

    return result

I'm pulling my hair out cause I can't figure out how this could happen. Any ideas?

Bartek Spitza
  • 305
  • 2
  • 15

0 Answers0