emailcontent = []
def getEmails(self):
self.browser.get("https://outlook.live.com/mail/0/inbox")
time.sleep(3)
content = self.browser.find_elements_by_css_selector("._2ZDUqsleGa-jar5wAYvVzV")
for c in content:
c.click() # opens the email
content = self.browser.find_element_by_dir("Itr").text
# div dir="Itr" only common tag for email contents
emailcontent.append(content)
getEmails()
txt = ""
for a in emailcontent:
txt += "{:<30} \n".format(a)
with open("new.txt", "a") as output:
output.write(txt)
os.startfile('new.txt')
I have a code as above, previous parts of codes basically enters my hotmail/outlook account and no any problem with them. I want this part to open every single email and save content to txt file but it doesnt happen. Only common tag for email contents are div dir="Itr" and I dont know how to find_element_... them one by one. Probably I need to use loops but I couldn't make it. Anyone wants to help?