import requests
# List of proxies
proxy_list = [
'proxy1.example.com:8000',
'proxy2.example.com:8000',
'proxy3.example.com:8000',
# Add more proxies as needed
]
# Function to rotate proxies
def get_proxy():
global proxy_list
proxy = proxy_list.pop(0)
proxy_list.append(proxy)
return {'http': 'http://' + proxy, 'https': 'https://' + proxy}
# Function to make a request using rotated proxy
def make_request(url):
try:
proxy = get_proxy()
response = requests.get(url, proxies=proxy)
if response.status_code == 200:
return response.text
else:
print(f"Request failed with status code: {response.status_code}")
return None
except Exception as e:
print(f"An error occurred: {str(e)}")
return None
# Example usage
if __name__ == "__main__":
target_url = 'http://example.com'
for _ in range(10): # Make 10 requests
response = make_request(target_url)
if response:
print(response)
else:
print("Request failed.")
يحدد هذا البرنامج النصي قائمة بالوكلاء ويوفر وظائف للتدوير من خلالها لكل طلب. يمكنك ضبط قائمة الوكيل وعنوان URL المستهدف وفقًا لمتطلباتك. تأكد من استبدال 'http://example.com'
باستخدام عنوان URL الذي تريد إرسال الطلبات إليه.
التعليقات (0)
لا توجد تعليقات هنا حتى الآن، يمكنك أن تكون الأول!