File size: 379 Bytes
f4ce1df
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
from bs4 import BeautifulSoup
import requests
import string

def get_image_from_url(url):
    try:
        r = requests.get(url)
        soup = BeautifulSoup(r.content, 'html.parser')
        img = soup.find('figure', 'thumbnail').find('img')
        return img['src']
    except:
        return None

depunctuate = lambda x: x.translate(str.maketrans('','',string.punctuation))