特牛网址导航

Python爬虫第一课,选取标签内容_网站爬虫返回空资源-CSDN文库

网友收藏
资源浏览查阅175次。Python爬虫第一课,选取标签内容,Python爬虫第一课,选取标签内容获取标题`#fromurllib.requestimporturlopen`#fromurllib.errorimportHTTPErrorfrombs4importBeautifulSoupdefgetTitle(url):try:html=urlopen(url)exceptHTTPErrorase:returnNonetry:bsObj=BeautifulSoup(html.read())title=bsObj.body.h1exceptAttributeErrorase:更多下载资源、学习资料请访问CSDN文库频道