sudo add-apt-repository ppa:fkrull/deadsnakes
sudo apt-get update
sudo apt-get install python2.7
sudo apt-get install python-bs4
Select any url to parse. I have selected the home page of this blog and opened that page with urlopen().
Pass the web page contents of 'page' variable to beautiful soup.
Lets print all the links which are present in this page.
from bs4 import BeautifulSoup
import urllib2
url = "https://www.goodreads.com/quotes/tag/love"
page = urllib2.urlopen(url)
soup = BeautifulSoup(page.read())
for anchor in soup.find_all('a'):
print(anchor.get('href', '/'))
python scrap_web_page.py