爬虫(一)
第一个爬虫虽然只有五行代码,但知道了很多知识:
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)