Created
August 26, 2016 06:09
-
-
Save suriyadeepan/b940caf6cba552527613c1f93e26cc80 to your computer and use it in GitHub Desktop.
Scrap images from a wiki page using Beautiful Soup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from bs4 import BeautifulSoup | |
import requests | |
url = 'https://en.wikipedia.org/wiki/Transhumanism' | |
# get contents from url | |
content = requests.get(url).content | |
# get soup | |
soup = BeautifulSoup(content,'lxml') # choose lxml parser | |
# find the tag : <img ... > | |
image_tags = soup.findAll('img') | |
# print out image urls | |
for image_tag in image_tags: | |
print(image_tag.get('src')) |
imagefile = open(filename + ".jpeg", 'wb')
imagefile.write(urllib.request.urlopen(image).read())
imagefile.close()
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
how i can download this imagenes?