Python, help with retrying a request if text is found on the page

Completado Publicado hace 5 años Pagado a la entrega
Completado Pagado a la entrega

So, I have a small piece of code that will retry the request if it failed eg status code 500.

What I need in place alongside that is if a piece of text on the page is found, to also retry the request until it's successful and/or doesn't find that piece of text on the page anymore.

So in short, while this piece of code checks for status errors in the page, I need one to hopefully be implemented into this code to look for text on the page and if its found retry the same request until the text is no longer there.

Note: I need the request to always use cookies as I use the cookies to login to the site without them it won't work.

Here's the code:

headers={'Accept': 'text/html',

'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36',

'Cookie':'xxxxx=xxxxx',

}

url = 'xxxxxxxxxxxxxxxxxxxxxxxxx'

json = [login to view URL]({'xxxxx' : 'xxxxx',

'xxxxx' : 'xxxxx',

'xxxxx' : '',

'xxxxx' : 'xxxxx',

'xxxxx' : 'xxxxx',

'xxxxx' : 'xxxxx'

,'xxxxx' : 'xxxxx'

,'xxxxx' : "xxxxx'})

req = [login to view URL](url, json, headers)

retries = 1

success = False

while not success:

try:

response = [login to view URL](req)

success = True

except Exception as e:

wait = retries * 20;

print [login to view URL]("[%I:%M:%S]"), 'Failed to complete, Waiting %s seconds and re-trying...' % wait

[login to view URL]()

[login to view URL](wait)

print [login to view URL]("[%I:%M:%S]"), "Success"

Python Arquitectura de software

Nº del proyecto: #17415199

Sobre el proyecto

6 propuestas Proyecto remoto Activo hace 5 años

Adjudicado a:

lordprasun

Looks like an easy fix.I guess 3 more lines would do it. P.s- I am Python developer with over 3 years of experience.

$15 AUD en 1 día
(13 comentarios)
3.3

6 freelancers están ofertando un promedio de $26 por este trabajo

yuriecojocari

I did some project with it Relevant Skills and Experience I do know a bit Proposed Milestones $35 AUD - working code

$35 AUD en 1 día
(4 comentarios)
2.4
anandkiller143

Will do it in python or bash shell script as per ur wish Relevant Skills and Experience bash scripting, shell scripting, python scripting Proposed Milestones $35 AUD - ENd to End SOlution

$35 AUD en 1 día
(0 comentarios)
0.0