1, first because the Mac comes with Python, version is python2.7.10
2, install PIP, because already have, so can not use brew install. Here with sudo easy_install pip
3, install beatifulsoup4,sudo-h PIP installs Beautifulsoup4. BeautifulSoup is a python library that extracts data from HTML or XML files. It is able to use your favorite converter to achieve the usual document navigation, find, modify the way the document.
4, install Html5lib,sudo PIP installs Html5lib. Html5lib is an HTML parsing library that is parsed in the same way as a browser
5. Script code:
From URLLIB2 import Urlopen
From BS4 import BeautifulSoup
html = Urlopen ("http://www.baidu.com")
res = BeautifulSoup (Html.read (), "Html5lib")
Print (Res.title)
6. Results:
The above is a small attempt today, record a bit. It's more motivating to learn.
Python first try to write a simple crawler program