python网络爬虫

1、

from urllib.request import urlopen
html = urlopen("http://pythonscraping.com/pages/page1.html")
print(html.read())

2、安装beautifulsoup:pip install beautifulsoup4

3、

from urllib.request import urlopen
from bs4 import BeautifulSoup
html = urlopen("http://pythonscraping.com/pages/page1.html")
bs = BeautifulSoup(html.read())
print(bs.h1)#读取h1这一行

 

posted on 2018-01-19 16:56  告辞  阅读(92)  评论(0)    收藏  举报

导航