130 lines
5.3 KiB
Python
130 lines
5.3 KiB
Python
import logging
|
|
import random
|
|
|
|
import requests
|
|
|
|
from utils.iproayl_stick_proxy_list import FR_IPROYAL_STICKY_PROXY_LIST
|
|
|
|
FR_ASOCKS_MOBILE_PROXY = {
|
|
'http': 'http://11797317-mobile-country-FR:nv958134x@190.2.151.110:14046',
|
|
'https': 'http://11797317-mobile-country-FR:nv958134x@190.2.151.110:14046',
|
|
}
|
|
|
|
FR_PROXY_RES_OXY = {
|
|
'http': 'http://customer-rendezvous-cc-FR:Rdv202220212023@pr.oxylabs.io:7777',
|
|
'https': 'http://customer-rendezvous-cc-FR:Rdv202220212023@pr.oxylabs.io:7777'
|
|
}
|
|
FR_PROXY_RES_PARIS_OXY = {
|
|
# customer-rendezvous-cc-fr-city-paris:PASSWORD@pr.oxylabs.io:7777
|
|
'http': 'http://customer-rendezvous-cc-fr-city-paris:Rdv202220212023@pr.oxylabs.io:7777',
|
|
'https': 'http://customer-rendezvous-cc-fr-city-paris:Rdv202220212023@pr.oxylabs.io:7777'
|
|
}
|
|
|
|
FR_PROXY_MOB_OXY = {
|
|
'http': 'http://customer-rendezvousmob-cc-FR:Rdv+20222021@pr.oxylabs.io:7777',
|
|
'https': 'http://customer-rendezvousmob-cc-FR:Rdv+20222021@pr.oxylabs.io:7777'
|
|
}
|
|
|
|
FR_PROXY_ASOCK_RES_2 = {
|
|
'http': 'http://zd6fbrujot-res-country-FR-hold-query:8k8avNlnLHQaMsWg@217.23.6.161:9999',
|
|
'https': 'http://zd6fbrujot-res-country-FR-hold-query:8k8avNlnLHQaMsWg@217.23.6.161:9999'
|
|
}
|
|
FR_PROXY_MOB_OXY_STICKY = {
|
|
'http': 'http://customer-rendezvousmob-cc-fr-sessid-0{}-sesstime-2:Rdv+202220212023@pr.oxylabs.io:7777',
|
|
'https': 'http://customer-rendezvousmob-cc-fr-sessid-0{}-sesstime-2:Rdv+202220212023@pr.oxylabs.io:7777'
|
|
}
|
|
|
|
FR_PROXY_DATA_IMPULSE_STICKY = {
|
|
'http': 'http://1d568220dbefeff21ad4__cr.fr:df99489a25fa72d9@gw.dataimpulse.com:{}',
|
|
'https': 'http://1d568220dbefeff21ad4__cr.fr:df99489a25fa72d9@gw.dataimpulse.com:{}'
|
|
}
|
|
|
|
FR_PROXY_RES_OXY_STICKY = {
|
|
'http': 'http://customer-rendezvous-cc-FR:Rdv202220212023@fr-pr.oxylabs.io:{}',
|
|
'https': 'http://customer-rendezvous-cc-FR:Rdv202220212023@fr-pr.oxylabs.io:{}'
|
|
}
|
|
FR_DATA_IMPULSE_RES = {
|
|
'http': 'http://ac2b8183c3b02714cbd1__cr.fr:336e7f8f4b17e5bd@gw.dataimpulse.com:823',
|
|
'https': 'http://ac2b8183c3b02714cbd1__cr.fr:336e7f8f4b17e5bd@gw.dataimpulse.com:823'
|
|
}
|
|
|
|
FR_MOBILE_ANY_IP_STICKY = {
|
|
'http': 'http://user_6a7f21,type_mobile,country_FR,session_{}:d5c051@portal.anyip.io:1080',
|
|
'https': 'http://user_6a7f21,type_mobile,country_FR,session_{}:d5c051@portal.anyip.io:1080',
|
|
}
|
|
FR_MOBILE_ANY_IP_ROTATING = {
|
|
'http': 'http://user_6a7f21,type_residential,country_FR:d5c051@portal.anyip.io:1080',
|
|
'https': 'http://user_6a7f21,type_residential,country_FR:d5c051@portal.anyip.io:1080',
|
|
}
|
|
FR_RES_IP_ROYAL_ROTATING = {
|
|
'http': 'http://Uv2qfG3PyhT6Wctw:V45HOlzAIssCYssJ_country-fr@geo.iproyal.com:12321',
|
|
'https': 'http://Uv2qfG3PyhT6Wctw:V45HOlzAIssCYssJ_country-fr@geo.iproyal.com:12321',
|
|
}
|
|
|
|
|
|
# MOBILE_PROXY_LIST = [FR_MOBILE_ANY_IP_STICKY, FR_PROXY_MOB_OXY_STICKY]
|
|
# MOBILE_PROXY_LIST = [FR_PROXY_MOB_OXY_STICKY]
|
|
MOBILE_PROXY_LIST = [FR_MOBILE_ANY_IP_STICKY]
|
|
|
|
|
|
class ProxyManager:
|
|
|
|
def __init__(self, logger):
|
|
self.logger = logger
|
|
|
|
def get_link_validate_proxy(self, links_to_validate: list) -> list:
|
|
# return [FR_PROXY_RES_PARIS_OXY]
|
|
# return [FR_MOBILE_ANY_IP_ROTATING]
|
|
return [FR_RES_IP_ROYAL_ROTATING]
|
|
# return [FR_PROXY_RES_OXY]
|
|
# if len(links_to_validate) > 15:
|
|
# return [FR_PROXY_RES_OXY, FR_PROXY_MOB_OXY, FR_PROXY_ASOCK_RES_2, FR_DATA_IMPULSE_RES]
|
|
# # return [FR_PROXY_RES_OXY, FR_PROXY_ASOCK_RES_2, FR_DATA_IMPULSE_RES, FR_ASOCKS_MOBILE_PROXY]
|
|
# else:
|
|
#
|
|
# return [FR_PROXY_RES_OXY, FR_PROXY_MOB_OXY, FR_PROXY_ASOCK_RES_2, FR_DATA_IMPULSE_RES]
|
|
# return [FR_PROXY_RES_OXY]
|
|
|
|
def get_random_sticky_iproyal_proxy(self) -> dict:
|
|
_session_info = random.choice(FR_IPROYAL_STICKY_PROXY_LIST)
|
|
_proxy_template = {
|
|
'http': 'http://{}@geo.iproyal.com:12321',
|
|
'https': 'http://{}@geo.iproyal.com:12321',
|
|
}
|
|
_proxy_to_use = {}
|
|
_proxy_to_use["http"] = _proxy_template["http"].format(_session_info)
|
|
_proxy_to_use["https"] = _proxy_template["https"].format(_session_info)
|
|
return _proxy_to_use
|
|
|
|
def get_result_link_proxy(self):
|
|
return [FR_PROXY_RES_OXY, FR_PROXY_ASOCK_RES_2, FR_DATA_IMPULSE_RES, FR_ASOCKS_MOBILE_PROXY]
|
|
|
|
def get_proxy_for_appointment_request(self) -> dict:
|
|
return self.get_random_sticky_iproyal_proxy()
|
|
# _chosen_proxy = random.choice(MOBILE_PROXY_LIST)
|
|
# if "oxylabs" in _chosen_proxy["http"]:
|
|
# self.logger.info("use oxylabs proxy")
|
|
# _port = random.randint(900000000, 995869818)
|
|
# elif "anyip" in _chosen_proxy["http"]:
|
|
# self.logger.info("use anyip proxy")
|
|
# _port = random.randint(40001, 49999)
|
|
# else:
|
|
# self.logger.info("use dataimpulse proxy")
|
|
# _port = random.randint(10000, 20000)
|
|
# self.logger.info("generated port is {}".format(_port))
|
|
# _proxy_to_use = {}
|
|
# _proxy_to_use["http"] = _chosen_proxy["http"].format(_port)
|
|
# _proxy_to_use["https"] = _chosen_proxy["https"].format(_port)
|
|
# return _proxy_to_use
|
|
|
|
|
|
if __name__ == '__main__':
|
|
_logger = logging.getLogger()
|
|
_proxy = ProxyManager(logger=_logger)
|
|
_proxise = _proxy.get_random_sticky_iproyal_proxy()
|
|
print(_proxise)
|
|
response = requests.get(
|
|
"https://ip.oxylabs.io/location",
|
|
proxies=_proxise)
|
|
print(response.content)
|