爬虫(一)

 

第一个爬虫虽然只有五行代码,但知道了很多知识:

from urllib.request import urlopen
from bs4 import BeautifulSoup
response =urlopen('http://www.baidu.com')
bs = BeautifulSoup(response.read(),"html.parser")
print (bs.title)

from urllib.request import urlopen
from bs4 import BeautifulSoup
response =urlopen('https://www.baidu.com')
bs = BeautifulSoup(response.read(),"html.parser")
print (bs.title)

 

 

posted @ 2019-05-15 17:59  殇之弑梦  阅读(116)  评论(0编辑  收藏  举报