for tag in tags: if tag.get("data-permalink-url") and not tag.get("data-permalink-url") in lstA: lstA.append(tag.get("data-permalink-url")) #print(lstA) #print(len(lstA)) lstB = list() for link in lstA: url = link resp = requests.get(url,headers=headers) # print(resp.status_code) resp.encoding = "utf-8" #print(resp.text) soup = BeautifulSoup(resp.text,"html.parser") tags = soup("li") for tag in tags: if tag.get("data-affiliation-id"): lstB.append(tag.contents[1]) #print(lstB) #print(len(lstB)) maillist = list() for text in lstB: if re.search("@",text): emails = re.findall("\S+@\S+\.[a-zA-Z0-9]+",text) for email in emails: if email in maillist:continue else:maillist.append(email) #print(maillist) print(len(maillist),"email address were retrived, done")