0

I've been trying to make a script that scrape 9gag and retreive posts from specific categories. The problem is when im trying to download the jpg pictures a certificate issue emerges.

Is there another way to download the pictures?

The url for each pictures can be presented somewhat like this:

https://img-9gag-fun.9cache.com/photo/aAgRxj0_460s.jpg https://img-9gag-fun.9cache.com/photo/aDgAx0N_460s.jpg

The code for downloading the images:

def download(pictures, file_name, name):
    for images in pictures['url_images']:
        full_path = file_name + name + '.jpg'
        urllib.request.urlretrieve(images, full_path)

The following result is presented:

urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1045)>
snaz
  • 41
  • 5
  • could you verify link? print one of pictures['url_images'] end manually get acces by webbrowser. Maybe just one link is broken? Print out each link in loop to check it. – Cas Aug 07 '19 at 13:21
  • Are you using a work or school computer? They usually get ssl errors – Alex Hawking Aug 07 '19 at 13:25
  • it seems error in C/C++ library `ssl` or `OpenSSL`. Maybe it needs to be updated. It may use old certifications. – furas Aug 07 '19 at 13:28
  • each link is solid and brings me to correct picture when i click the link @kacper – snaz Aug 07 '19 at 19:56
  • neither, currently using a macbook if that has something to do with the problem?@AlexHawking – snaz Aug 07 '19 at 19:57
  • I tried to update something called certifi without any sucess. Currently using Macbook Pro with Mojave 10.14.5 on it@furas – snaz Aug 07 '19 at 19:57

1 Answers1

0

Presuming your using python3 and urllib3 maybe try this:

urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

Not sure if this will help but fixed ssl errors I was getting when urllib.

Alex Hawking
  • 1,125
  • 5
  • 19
  • 35