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