0

I am trying to scrape links from Yahoo emails but keep getting the following error. I have tried adding a sleep condition but it does not seem to have made any difference.

Response status "ok" expected but "no" received. Data: [b'[SERVERBUG] SELECT Server error - Please try again later']

Can anyone see what the issue is?

from imap_tools import MailBox, AND
import re, time, datetime, os
from config import email, password

uids = []
yahooSmtpServer = "imap.mail.yahoo.com"
while True:
    while True:
        try:
            client = MailBox(yahooSmtpServer).login(email, password, 'INBOX')
            try:
                msgs = client.fetch(AND(seen=False))
                for msg in msgs:
                    links = []
                    if str(datetime.datetime.today()).split(' ')[0] == str(msg.date).split(' ')[0]:
                    #if str(msg.date).split(' ')[0].split('-')[0] == '2021' and str(msg.date).split(' ')[0].split('-')[1] == '06' and not msg.uid in uids:
                        mail = msg.html
                        #uids.append(msg.uid)
                        if 'order' in mail and not 'return' in mail:
                            for i in re.findall(r'(https?://[^\s]+)', mail):
                                if 'pick' in i:
                                    link = i.replace('"', "")
                                    link = link.replace('<', '>').split('>')[0]
                                    print(link)
                                    os.system('start cmd /c python scrap.py '+ link + ' && exit')
                        
                                    break
                        client.seen(msg.uid, True)
            except Exception as e:
                print(e)
                pass
            client.logout()
            time.sleep(5)
        except Exception as e:
            print(e)
            print('sleeping for 5 sec')
            time.sleep(1)
Andy
  • 509
  • 2
  • 7

1 Answers1

2

It looks like you have spammed the server.

Vladimir
  • 6,162
  • 2
  • 32
  • 36