python爬虫初步认知

import requests        #导入requests包
from bs4 import BeautifulSoup

url='http://www.cntour.cn/'
strhtml=requests.get(url)
content = strhtml.text
print(content)
print("============")
soup = BeautifulSoup(content,'lxml')#选择lxml作为解析器
print(soup.div['id'])
print(soup.title)

  

posted @ 2020-05-18 14:51  不不田鼠  阅读(153)  评论(0编辑  收藏  举报