We use the module urllib2 to download webpage data. Any webpage is formatted using a markup language known as HTML.
Extracting image links:
To extract all image links use:
from BeautifulSoup import BeautifulSoup |
Explanation
First we import the required modules:
from BeautifulSoup import BeautifulSoup |
We get the webpage data using:html_page = urllib2.urlopen("http://imgur.com")
Then we extract all image links using:images = []
for img in soup.findAll('img'):
images.append(img.get('src'))
Finally we print the links:print(links)