import requests from bs4 import BeautifulSoup apex_class = '' apex_trigger = '' custome_object = '' profile = '' others = '' path = '/Users/aaa/Downloads/aaa.htm' htmlfile = open(path, 'r') htmlhandle = htmlfile.read() soup = BeautifulSoup(htmlhandle, "lxml") #soup = BeautifulSoup(htmlhandle, "html.parser") titles = soup.find_all("a", class_="link-gray-dark") for title in titles: if 'src' in title.text: if '.cls' in title.text: apex_class += ' '+title.text elif '.trigger' in title.text: apex_trigger += ' '+title.text elif '.object' in title.text: custome_object += ' '+title.text elif '.profile' in title.text: profile += ' '+title.text else: others += ' '+title.text print ('apex_class: '+apex_class); print ('apex_trigger: '+apex_trigger); print ('custome_object: '+custome_object); print ('profile: '+profile); print ('others: '+others);