0

I'm trying to loop around a list in python to use as parameters to send to a site. However, sometimes, the request is returning time-out errors. How would I be able to stay in the current loop until the source is met?

import requests
URL = 'https://name.com/'
Names = ['Bob', 'Andy', 'Mike']

for i in Names:
    callback = requests.get(url=URL, params=i)
    source = callback.text

    if i in source:
        print("Found it")

    else:
        #retry

The list is already filtered beforehand in order to make sure it is suitable to be inputted as a parameter. So what I'm trying to say is the contents in the list will always provide a valid source.

poisonishere
  • 43
  • 1
  • 7

1 Answers1

1

E.g. Like this:

import requests
URL = 'https://name.com/'
Names = ['Bob', 'Andy', 'Mike']

for i in Names: 

    while True:

        callback = requests.get(url=URL, params=i)
        source = callback.text

        if i in source:
            print("Found it")
            break
skymon
  • 850
  • 1
  • 12
  • 19