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

Completed Posted 5 years ago Paid on delivery
Completed Paid on delivery

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 Software Architecture

Project ID: #17415199

About the project

7 proposals Remote project Active 5 years ago

Awarded to:

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 in 1 day
(13 Reviews)
3.3

7 freelancers are bidding on average $26 for this job

yuriecojocari

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

$35 AUD in 1 day
(4 Reviews)
2.4
Tkost

As I understand, you need to check for a certain text on the site. Relevant Skills and Experience I have experience of working with HTTP libraries. I am sure, I can help you with your project. Proposed Milestones $25 More

$25 AUD in 1 day
(3 Reviews)
1.8
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 in 1 day
(0 Reviews)
0.0