Python爬虫第一课选取标签内容
Python爬虫第一课,选取标签内容 获取标题`# from urllib.request import urlopen `# from urllib.error import HTTPError from bs4 import BeautifulSoup def getTitle(url): try: html = urlopen(url) except HTTPError as e: return None try: bsObj = BeautifulSoup(html.read()) title = bsObj.body.h1 except AttributeError as e:
下载地址
用户评论