1     def getTitle(self,url):
 2         #get title
 3         title = 'time out'
 4         try:
 5             self.res = requests.get(url,timeout=5)
 6             
 7 
 8             soup = BeautifulSoup(self.res.text, 'lxml')
 9             
10             title = soup.title.text
11            
12         except Exception:
13             title = self.res.text
14         
15         return title

 

posted on 2018-10-11 15:45  小白闯天下  阅读(147)  评论(0编辑  收藏  举报