Merge branch 'feature/5_0_2' of git.lpaconsulting.fr:panleicim/appointment_request into feature/5_0_2
This commit is contained in:
@@ -29,6 +29,7 @@ class ReserveResultPojo:
|
|||||||
slot_position = None
|
slot_position = None
|
||||||
sim_position = None
|
sim_position = None
|
||||||
ccid: str = ""
|
ccid: str = ""
|
||||||
|
model: str = ""
|
||||||
source_from: str = socket.gethostname()
|
source_from: str = socket.gethostname()
|
||||||
store_type = 0
|
store_type = 0
|
||||||
url_validated = None
|
url_validated = None
|
||||||
@@ -122,8 +123,7 @@ class ReserveResultPojo:
|
|||||||
u'email': self.email,
|
u'email': self.email,
|
||||||
u'passport': self.passport,
|
u'passport': self.passport,
|
||||||
u'url': self.url,
|
u'url': self.url,
|
||||||
# u'sim_position': self.sim_position,
|
u'model': self.model,
|
||||||
# u'slot_position': self.slot_position,
|
|
||||||
u'source_from': self.source_from,
|
u'source_from': self.source_from,
|
||||||
u'hostName': self.source_from,
|
u'hostName': self.source_from,
|
||||||
u'created_at': self.created_at,
|
u'created_at': self.created_at,
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
|
import logging
|
||||||
import random
|
import random
|
||||||
|
|
||||||
|
import requests
|
||||||
|
|
||||||
FR_ASOCKS_MOBILE_PROXY = {
|
FR_ASOCKS_MOBILE_PROXY = {
|
||||||
'http': 'http://11797317-mobile-country-FR:nv958134x@190.2.151.110:14046',
|
'http': 'http://11797317-mobile-country-FR:nv958134x@190.2.151.110:14046',
|
||||||
'https': 'http://11797317-mobile-country-FR:nv958134x@190.2.151.110:14046',
|
'https': 'http://11797317-mobile-country-FR:nv958134x@190.2.151.110:14046',
|
||||||
@@ -25,8 +28,8 @@ FR_PROXY_ASOCK_RES_2 = {
|
|||||||
'https': '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 = {
|
FR_PROXY_MOB_OXY_STICKY = {
|
||||||
'http': 'http://customer-rendezvousmob-cc-FR:Rdv202220212023@fr-pr.oxylabs.io:{}',
|
'http': 'http://customer-rendezvousmob-cc-fr-sessid-0{}-sesstime-2:Rdv+202220212023@pr.oxylabs.io:7777',
|
||||||
'https': 'http://customer-rendezvousmob-cc-FR:Rdv202220212023@fr-pr.oxylabs.io:{}'
|
'https': 'http://customer-rendezvousmob-cc-fr-sessid-0{}-sesstime-2:Rdv+202220212023@pr.oxylabs.io:7777'
|
||||||
}
|
}
|
||||||
|
|
||||||
FR_PROXY_DATA_IMPULSE_STICKY = {
|
FR_PROXY_DATA_IMPULSE_STICKY = {
|
||||||
@@ -59,12 +62,11 @@ FR_MOBILE_ANY_IP_ROTATING = {
|
|||||||
# FR_PROXY_DATA_IMPULSE_STICKY]
|
# FR_PROXY_DATA_IMPULSE_STICKY]
|
||||||
|
|
||||||
|
|
||||||
|
# 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]
|
MOBILE_PROXY_LIST = [FR_MOBILE_ANY_IP_STICKY]
|
||||||
|
|
||||||
|
|
||||||
# MOBILE_PROXY_LIST = [FR_MOBILE_ANY_IP_STICKY]
|
|
||||||
|
|
||||||
|
|
||||||
class ProxyManager:
|
class ProxyManager:
|
||||||
|
|
||||||
def __init__(self, logger):
|
def __init__(self, logger):
|
||||||
@@ -72,7 +74,8 @@ class ProxyManager:
|
|||||||
|
|
||||||
def get_link_validate_proxy(self, links_to_validate: list) -> list:
|
def get_link_validate_proxy(self, links_to_validate: list) -> list:
|
||||||
# return [FR_PROXY_RES_PARIS_OXY]
|
# return [FR_PROXY_RES_PARIS_OXY]
|
||||||
return [FR_MOBILE_ANY_IP_ROTATING]
|
# return [FR_MOBILE_ANY_IP_ROTATING]
|
||||||
|
return [FR_PROXY_RES_OXY]
|
||||||
# if len(links_to_validate) > 15:
|
# 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_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]
|
# # return [FR_PROXY_RES_OXY, FR_PROXY_ASOCK_RES_2, FR_DATA_IMPULSE_RES, FR_ASOCKS_MOBILE_PROXY]
|
||||||
@@ -88,7 +91,7 @@ class ProxyManager:
|
|||||||
_chosen_proxy = random.choice(MOBILE_PROXY_LIST)
|
_chosen_proxy = random.choice(MOBILE_PROXY_LIST)
|
||||||
if "oxylabs" in _chosen_proxy["http"]:
|
if "oxylabs" in _chosen_proxy["http"]:
|
||||||
self.logger.info("use oxylabs proxy")
|
self.logger.info("use oxylabs proxy")
|
||||||
_port = random.randint(40001, 49999)
|
_port = random.randint(900000000, 995869818)
|
||||||
elif "anyip" in _chosen_proxy["http"]:
|
elif "anyip" in _chosen_proxy["http"]:
|
||||||
self.logger.info("use anyip proxy")
|
self.logger.info("use anyip proxy")
|
||||||
_port = random.randint(40001, 49999)
|
_port = random.randint(40001, 49999)
|
||||||
@@ -100,3 +103,14 @@ class ProxyManager:
|
|||||||
_proxy_to_use["http"] = _chosen_proxy["http"].format(_port)
|
_proxy_to_use["http"] = _chosen_proxy["http"].format(_port)
|
||||||
_proxy_to_use["https"] = _chosen_proxy["https"].format(_port)
|
_proxy_to_use["https"] = _chosen_proxy["https"].format(_port)
|
||||||
return _proxy_to_use
|
return _proxy_to_use
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
_logger = logging.getLogger()
|
||||||
|
_proxy = ProxyManager(logger=_logger)
|
||||||
|
_proxise = _proxy.get_proxy_for_appointment_request()
|
||||||
|
print(_proxise)
|
||||||
|
response = requests.get(
|
||||||
|
"https://ip.oxylabs.io/location",
|
||||||
|
proxies=_proxise)
|
||||||
|
print(response.content)
|
||||||
|
|||||||
@@ -180,6 +180,8 @@ class LinkValidatorWithProvidedList(threading.Thread):
|
|||||||
ch.basic_reject(delivery_tag=method.delivery_tag, requeue=True)
|
ch.basic_reject(delivery_tag=method.delivery_tag, requeue=True)
|
||||||
else:
|
else:
|
||||||
print("will ack")
|
print("will ack")
|
||||||
|
print("will wait for 40s")
|
||||||
|
time.sleep(20)
|
||||||
ch.basic_ack(delivery_tag=method.delivery_tag)
|
ch.basic_ack(delivery_tag=method.delivery_tag)
|
||||||
else:
|
else:
|
||||||
print("empty list, will republish message")
|
print("empty list, will republish message")
|
||||||
@@ -242,7 +244,7 @@ def validate_all_links(_contact_serial_list):
|
|||||||
if len(_first_25_percent_links) >= 10:
|
if len(_first_25_percent_links) >= 10:
|
||||||
_segment_number = 10
|
_segment_number = 10
|
||||||
else:
|
else:
|
||||||
_segment_number = 1
|
_segment_number = len(_first_25_percent_links)
|
||||||
for i in range(0, _segment_number):
|
for i in range(0, _segment_number):
|
||||||
logger.info("{}:{} links to validate".format(threading.currentThread().name, len(_first_25_percent_links)))
|
logger.info("{}:{} links to validate".format(threading.currentThread().name, len(_first_25_percent_links)))
|
||||||
logger.info("segment is {}".format(i))
|
logger.info("segment is {}".format(i))
|
||||||
|
|||||||
+6
-4
@@ -38,7 +38,8 @@ class Sender:
|
|||||||
self.proxy_to_use = proxy_to_use
|
self.proxy_to_use = proxy_to_use
|
||||||
self.cookie.load(self.cookie_str)
|
self.cookie.load(self.cookie_str)
|
||||||
|
|
||||||
def publish_message_to_queue(self, contact: ContactPojo, status: PublishType, url: str, store_type: str):
|
def publish_message_to_queue(self, contact: ContactPojo, status: PublishType, url: str, store_type: str,
|
||||||
|
model: str = ""):
|
||||||
# create the message
|
# create the message
|
||||||
if url == "https://rendezvousparis.hermes.com/client/welcome":
|
if url == "https://rendezvousparis.hermes.com/client/welcome":
|
||||||
return
|
return
|
||||||
@@ -59,11 +60,12 @@ class Sender:
|
|||||||
result.proxy = "data_impulse"
|
result.proxy = "data_impulse"
|
||||||
result.id = id
|
result.id = id
|
||||||
result.store_type = store_type
|
result.store_type = store_type
|
||||||
|
result.model = model
|
||||||
result.created_at = time.strftime("%H:%M:%S", time.localtime())
|
result.created_at = time.strftime("%H:%M:%S", time.localtime())
|
||||||
collection_name = str(datetime.date.today())
|
collection_name = str(datetime.date.today())
|
||||||
MONGO_STORE_MANAGER.insert_reserve_result(collection_name=collection_name, reserve=result)
|
MONGO_STORE_MANAGER.insert_reserve_result(collection_name=collection_name, reserve=result)
|
||||||
|
|
||||||
def apply_redirect(self, response, old_headers, contact, js_data, selected_store):
|
def apply_redirect(self, response, old_headers, contact, js_data, selected_store, model=""):
|
||||||
# /client/register/5XD2E2
|
# /client/register/5XD2E2
|
||||||
_res_headers = response.headers
|
_res_headers = response.headers
|
||||||
_location = _res_headers['location']
|
_location = _res_headers['location']
|
||||||
@@ -87,7 +89,7 @@ class Sender:
|
|||||||
contact.current_ip = get_address_ip(proxy_to_use=self.proxy_to_use)
|
contact.current_ip = get_address_ip(proxy_to_use=self.proxy_to_use)
|
||||||
_appointment_url = _redirect_url
|
_appointment_url = _redirect_url
|
||||||
self.publish_message_to_queue(contact, status=PublishType.SUCCESS, url=_appointment_url,
|
self.publish_message_to_queue(contact, status=PublishType.SUCCESS, url=_appointment_url,
|
||||||
store_type=selected_store)
|
store_type=selected_store, model=model)
|
||||||
self.cookie.load(_cookies_to_set)
|
self.cookie.load(_cookies_to_set)
|
||||||
new_cookies = {k: v.value for k, v in self.cookie.items()}
|
new_cookies = {k: v.value for k, v in self.cookie.items()}
|
||||||
new_coolies_str = ""
|
new_coolies_str = ""
|
||||||
@@ -175,7 +177,7 @@ class Sender:
|
|||||||
# add to mongodb
|
# add to mongodb
|
||||||
self.logger.info(response.text)
|
self.logger.info(response.text)
|
||||||
self.apply_redirect(response=response, old_headers=headers, contact=contact, js_data=js_data,
|
self.apply_redirect(response=response, old_headers=headers, contact=contact, js_data=js_data,
|
||||||
selected_store=_selected_store)
|
selected_store=_selected_store, model=model)
|
||||||
# self.logger.info("{}:{}".format(contact.mail, response.url))
|
# self.logger.info("{}:{}".format(contact.mail, response.url))
|
||||||
# contact.ua = js_data.ua
|
# contact.ua = js_data.ua
|
||||||
# contact.current_ip = get_address_ip(proxy_to_use=proxy_to_use)
|
# contact.current_ip = get_address_ip(proxy_to_use=proxy_to_use)
|
||||||
|
|||||||
Reference in New Issue
Block a user