Python Forum
Running A Loop Until You See A Particular Result
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Running A Loop Until You See A Particular Result
#2
You might can use a try except clause. Something like. Code not tested.

#! /usr/bin/env python3

import requests as rq
import random as rnd
import copy

url = 'testurl.com'

proxy_list = ['173.68.59.131:3128','64.124.38.139:8080','69.197.181.202:3128']
proxy_copy = copy.deepcopy(proxy_list)

while proxy_copy:
    rnd.shuffle(proxy_copy)
    proxy = proxy_copy.pop()
    try:
        response = rq.get(url, headers=headers, proxies={'https':proxy}, timeout=3)
        print(response.status_code)
    except NameError as error:
        print(error)
        continue
I welcome all feedback.
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags


Reply


Messages In This Thread
RE: Running A Loop Until You See A Particular Result - by menator01 - Sep-01-2021, 08:07 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  help RuntimeError: no running event loop marpaslight 5 3,754 Oct-18-2022, 10:04 PM
Last Post: marpaslight
  code running for more than an hour now, yet didn't get any result, what should I do? aiden 2 1,516 Apr-06-2022, 03:41 PM
Last Post: Gribouillis
  bleak library RuntimeError: This event loop is already running alice93 3 4,117 Sep-30-2021, 08:06 AM
Last Post: alice93
  loop running indefinitely shantanu97 6 2,600 Sep-29-2021, 08:03 PM
Last Post: deanhystad
  Running loop at specific frequency mdsousa 3 5,960 Apr-21-2021, 11:22 AM
Last Post: jefsummers
  Noob Alert! Wrong result using loop and if statemnent GJG 7 2,902 Dec-19-2020, 05:18 PM
Last Post: buran
  RuntimeError: This event loop is already running newbie2019 2 6,963 Sep-30-2020, 06:59 PM
Last Post: forest44
  Running function from parent module which has a loop in it. ta2909i 1 2,695 Nov-18-2019, 07:04 PM
Last Post: Gribouillis
  How to add coroutine to a running event loop? AlekseyPython 1 8,172 Mar-21-2019, 06:04 PM
Last Post: nilamo
  action on MQTT while long loop is running runboy 4 6,112 Oct-05-2018, 11:57 PM
Last Post: runboy

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020