Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load i.redd.it image urls #26

Closed
Elucidation opened this issue Sep 5, 2016 · 0 comments
Closed

Load i.redd.it image urls #26

Elucidation opened this issue Sep 5, 2016 · 0 comments
Assignees

Comments

@Elucidation
Copy link
Owner

Currently the bot is not able to load the images from i.redd.it links because of HTML Error 403: Forbidden, which is due to Reddit blocking bot bulk image retrieval.

def loadImageFromURL(img_url):
  """Load PIL image from URL, keep as color"""
   return PIL.Image.open(StringIO(urllib.urlopen(img_url).read()))

We can get around this using urllib2 Requests with a user agent in the header, as described on http://stackoverflow.com/questions/3336549/pythons-urllib2-why-do-i-get-error-403-when-i-urlopen-a-wikipedia-page

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant