can run exe file
This commit is contained in:
+20
-13
@@ -1,3 +1,4 @@
|
||||
import logging
|
||||
import random
|
||||
import threading
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
@@ -10,14 +11,10 @@ import params
|
||||
from workers.commandor_page import get_random_id_number_for_proxy
|
||||
from logs.LogSender import TYPE_EVENT_CHECK_RESULTS, LOG_SUBJECT_EVENT
|
||||
from pojo.ReserveResultPojo import ReserveResultPojo
|
||||
from utils.excel_reader import ExcelHelper
|
||||
|
||||
SORRY_SENTENCE = "nous sommes sincèrement désolés de n'avoir pu vous satisfaire cette fois-ci"
|
||||
PENDING_SENTENCE = "Ce soir, entre 20:00 et 20:30, vous obtiendrez une réponse par e-mail."
|
||||
|
||||
user_agent_list = ExcelHelper().read_user_agent_list()
|
||||
|
||||
|
||||
class ResultEnum(Enum):
|
||||
ACCEPTED = "ACCEPTED"
|
||||
REFUSED = "REFUSED"
|
||||
@@ -33,17 +30,27 @@ class Tls(threading.local):
|
||||
class Worker:
|
||||
tls = Tls()
|
||||
|
||||
def __init__(self):
|
||||
self.logger = logging.getLogger("Worker")
|
||||
|
||||
def load_page(self, browser, url, proxy) -> Union[str, None]:
|
||||
try:
|
||||
firefox_user_agents = filter(lambda user_agent: "firefox" in user_agent.lower(), user_agent_list)
|
||||
firefox_user_agents_list = list(firefox_user_agents)
|
||||
user_agent = random.choice(firefox_user_agents_list)
|
||||
page = browser.new_page(
|
||||
user_agent=user_agent,
|
||||
proxy=proxy)
|
||||
page.add_init_script("""() => Object.defineProperty(navigator,'webdriver',{get: () => undefined}""")
|
||||
page.goto(url, timeout=90000)
|
||||
return page.content()
|
||||
device = random.choice(params.DEVICES)
|
||||
self.logger.info("device is " + device)
|
||||
pixel_2 = self.tls.playwright.devices[device]
|
||||
context = browser.new_context(**pixel_2, locale='en-GB')
|
||||
self.page = context.new_page()
|
||||
# hide webdriver information
|
||||
self.page.add_init_script("""() => {
|
||||
Object.defineProperty(navigator,'webdriver',{get: () => undefined});
|
||||
Object.defineProperty(navigator, 'platform', {
|
||||
get: () => {
|
||||
return "iPhone";
|
||||
}});
|
||||
}
|
||||
""")
|
||||
self.page.goto(url, timeout=90000)
|
||||
return self.page.content()
|
||||
except Exception as error:
|
||||
print(error)
|
||||
return None
|
||||
|
||||
+3
-53
@@ -3,10 +3,8 @@ import json
|
||||
import pandas as pandas
|
||||
|
||||
import definitions
|
||||
import params
|
||||
from pojo.SimInfoPojo import SimInfoPojo
|
||||
from definitions import CONTACT_LIST_FILE
|
||||
from pojo.contact_pojo import ContactPojo
|
||||
from utils.operator import check_operator
|
||||
|
||||
|
||||
class ExcelHelper:
|
||||
@@ -19,50 +17,8 @@ class ExcelHelper:
|
||||
self._df = pandas.concat([self._df, new_df])
|
||||
self._df.to_excel(file_name)
|
||||
|
||||
def generate_exel_from_txt(self):
|
||||
f = open("../phone_list.txt")
|
||||
lines = f.read()
|
||||
self.write_to_exel("phone_list.xlsx", lines.split(","))
|
||||
ccid_file = open("../ccid_list.txt")
|
||||
ccids = ccid_file.read()
|
||||
self.write_to_exel("ccid_list.xlsx", ccids.split(","))
|
||||
print(lines)
|
||||
|
||||
def read_user_agent_list(self):
|
||||
# read the contact list from the exel file
|
||||
contact_list_in_json = pandas.read_excel(definitions.ROOT_DIR + "/docs/mobile_user_agent_list.xlsx").to_json(
|
||||
orient='records')
|
||||
contact_dict_list = json.loads(contact_list_in_json)
|
||||
user_agents = []
|
||||
for contact_dict in contact_dict_list:
|
||||
user_agent = contact_dict['user_agent']
|
||||
user_agents.append(user_agent)
|
||||
return user_agents
|
||||
|
||||
def read_sim_info(self) -> list:
|
||||
sim_info_list_in_json = pandas.read_excel(definitions.ROOT_DIR + "/docs/sim_infos.xlsx").to_json(orient='records')
|
||||
sim_info_dict_list = json.loads(sim_info_list_in_json)
|
||||
sim_info_list = []
|
||||
for contact_dict in sim_info_dict_list:
|
||||
position = contact_dict['position']
|
||||
slot_position = int(int(position) / len(params.MODEM_POOL_PORTS)) + 1
|
||||
sim_position = int(position) % len(params.MODEM_POOL_PORTS)
|
||||
ccid = contact_dict['ccid']
|
||||
operator = check_operator(ccid).name
|
||||
siminfo = SimInfoPojo(phone=contact_dict['phone'],
|
||||
name=contact_dict['name'],
|
||||
ccid=ccid,
|
||||
passport=contact_dict['passport'],
|
||||
position=contact_dict['position'],
|
||||
slot_position=slot_position,
|
||||
sim_position=sim_position,
|
||||
operator=operator,
|
||||
email=contact_dict['email'])
|
||||
sim_info_list.append(siminfo)
|
||||
return sim_info_list
|
||||
|
||||
def read_contacts(self, file_name="/contact_all.xlsx") -> list:
|
||||
contact_list_in_json = pandas.read_excel(definitions.ROOT_DIR + file_name).to_json(orient='records')
|
||||
def read_contacts(self, file_name=CONTACT_LIST_FILE) -> list:
|
||||
contact_list_in_json = pandas.read_excel(file_name).to_json(orient='records')
|
||||
contact_dict_list = json.loads(contact_list_in_json)
|
||||
contact_list = []
|
||||
for contact_dict in contact_dict_list:
|
||||
@@ -76,9 +32,3 @@ class ExcelHelper:
|
||||
mail=contact_dict['email'])
|
||||
contact_list.append(contact)
|
||||
return contact_list
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
helper = ExcelHelper()
|
||||
# helper.generate_exel_from_txt()
|
||||
print(helper.read_sim_info())
|
||||
|
||||
Reference in New Issue
Block a user