Merge branch 'feature/proxy'
This commit is contained in:
+18
-3
@@ -8,10 +8,13 @@ KEY_START_NUMBER = "KEY_START_NUMBER"
|
|||||||
KEY_END_NUMBER = "KEY_END_NUMBER"
|
KEY_END_NUMBER = "KEY_END_NUMBER"
|
||||||
KEY_MAX_WORKERS = "KEY_MAX_WORKERS"
|
KEY_MAX_WORKERS = "KEY_MAX_WORKERS"
|
||||||
KEY_RANDOM = "KEY_RANDOM"
|
KEY_RANDOM = "KEY_RANDOM"
|
||||||
|
KEY_PROXY_RES = "KEY_PROXY_RES"
|
||||||
|
KEY_PROXY_CC = "KEY_PROXY_CC"
|
||||||
KEY_FAUBOURG = "KEY_FAUBOURG"
|
KEY_FAUBOURG = "KEY_FAUBOURG"
|
||||||
KEY_GEORGE = "KEY_GEORGE"
|
KEY_GEORGE = "KEY_GEORGE"
|
||||||
KEY_SEVRES = "KEY_SEVRES"
|
KEY_SEVRES = "KEY_SEVRES"
|
||||||
GROUP_STORE = "STORE"
|
GROUP_STORE = "STORE"
|
||||||
|
GROUP_PROXY = "GROUP_PROXY"
|
||||||
|
|
||||||
file_list_column = [
|
file_list_column = [
|
||||||
[sg.Text('请输入联系人表的起始和结束行')],
|
[sg.Text('请输入联系人表的起始和结束行')],
|
||||||
@@ -21,18 +24,24 @@ file_list_column = [
|
|||||||
[sg.Submit(button_text="运行", key="submit")]
|
[sg.Submit(button_text="运行", key="submit")]
|
||||||
]
|
]
|
||||||
# For now will only show the name of the file that was chosen
|
# For now will only show the name of the file that was chosen
|
||||||
settings_column = [
|
store_settings_column = [
|
||||||
[sg.Text("目标商店")],
|
[sg.Text("目标商店")],
|
||||||
[sg.Radio('随机', group_id=GROUP_STORE, key=KEY_RANDOM, default=True)],
|
[sg.Radio('随机', group_id=GROUP_STORE, key=KEY_RANDOM, default=True)],
|
||||||
[sg.Radio('Hermès Faubourg Saint-Honoré', group_id=GROUP_STORE, key=KEY_FAUBOURG, default=False)],
|
[sg.Radio('Hermès Faubourg Saint-Honoré', group_id=GROUP_STORE, key=KEY_FAUBOURG, default=False)],
|
||||||
[sg.Radio('Hermès George V', group_id=GROUP_STORE, key=KEY_GEORGE, default=False)],
|
[sg.Radio('Hermès George V', group_id=GROUP_STORE, key=KEY_GEORGE, default=False)],
|
||||||
[sg.Radio('Hermès Sèvres', group_id=GROUP_STORE, key=KEY_SEVRES, default=False)]
|
[sg.Radio('Hermès Sèvres', group_id=GROUP_STORE, key=KEY_SEVRES, default=False)]
|
||||||
]
|
]
|
||||||
|
proxy_settings_column = [
|
||||||
|
[sg.Text("代理ip池")],
|
||||||
|
[sg.Radio('res(速度)', group_id=GROUP_PROXY, key=KEY_PROXY_RES, default=True)],
|
||||||
|
[sg.Radio('cc(稳定)', group_id=GROUP_PROXY, key=KEY_PROXY_CC, default=False)],
|
||||||
|
]
|
||||||
# ----- Full layout -----
|
# ----- Full layout -----
|
||||||
layout = [
|
layout = [
|
||||||
[
|
[
|
||||||
sg.Column(file_list_column),
|
sg.Column(file_list_column),
|
||||||
sg.Column(settings_column)
|
sg.Column(store_settings_column),
|
||||||
|
sg.Column(proxy_settings_column)
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -54,7 +63,13 @@ while True:
|
|||||||
store_type = 2
|
store_type = 2
|
||||||
elif values[KEY_SEVRES]:
|
elif values[KEY_SEVRES]:
|
||||||
store_type = 3
|
store_type = 3
|
||||||
start_book(start_line, end_line, store_choose_state=store_type, max_workers=max_workers)
|
|
||||||
|
proxy_type = 0
|
||||||
|
if values[KEY_PROXY_CC]:
|
||||||
|
proxy_type = 1
|
||||||
|
elif values[KEY_PROXY_RES]:
|
||||||
|
proxy_type = 0
|
||||||
|
start_book(start_line, end_line, store_choose_state=store_type, max_workers=max_workers, proxy_type=proxy_type)
|
||||||
# except Exception as error:
|
# except Exception as error:
|
||||||
# print("Not Integer: ")
|
# print("Not Integer: ")
|
||||||
# print(error)
|
# print(error)
|
||||||
|
|||||||
+1
-1
@@ -52,4 +52,4 @@ import shutil
|
|||||||
shutil.copyfile('./appointment.json', '{0}/appointment.json'.format(DISTPATH))
|
shutil.copyfile('./appointment.json', '{0}/appointment.json'.format(DISTPATH))
|
||||||
shutil.copyfile('./contact_all.xlsx', '{0}/contact_all.xlsx'.format(DISTPATH))
|
shutil.copyfile('./contact_all.xlsx', '{0}/contact_all.xlsx'.format(DISTPATH))
|
||||||
shutil.copyfile('./config.ini', '{0}/config.ini'.format(DISTPATH))
|
shutil.copyfile('./config.ini', '{0}/config.ini'.format(DISTPATH))
|
||||||
shutil.copytree('./venv\Lib/site-packages/grpc/_cython/_credentials', '{0}/appointment/grpc/_cython/_credentials'.format(DISTPATH))
|
#shutil.copytree('./venv/Lib/site-packages/grpc/_cython/_credentials', '{0}/appointment/grpc/_cython/_credentials'.format(DISTPATH))
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
import configparser
|
import configparser
|
||||||
import os
|
import os
|
||||||
import getpass
|
import getpass
|
||||||
|
|
||||||
config = configparser.ConfigParser()
|
config = configparser.ConfigParser()
|
||||||
config.read('./config.ini')
|
config.read('./config.ini')
|
||||||
CONTACT_LIST_FILE = config['DEFAULT']['contact_list_file']
|
CONTACT_LIST_FILE = config['DEFAULT']['contact_list_file']
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ logger = logging.getLogger()
|
|||||||
logger.addHandler(logging.StreamHandler(stream=sys.stdout))
|
logger.addHandler(logging.StreamHandler(stream=sys.stdout))
|
||||||
|
|
||||||
|
|
||||||
def start_book(start_number, end_number, store_choose_state=0, max_workers=10):
|
def start_book(start_number, end_number, store_choose_state=0, max_workers=10, proxy_type=0):
|
||||||
# read the contact, and contact the 2 objects together
|
# read the contact, and contact the 2 objects together
|
||||||
excel_reader = ExcelHelper()
|
excel_reader = ExcelHelper()
|
||||||
all_contacts = excel_reader.read_contacts()
|
all_contacts = excel_reader.read_contacts()
|
||||||
@@ -23,14 +23,16 @@ def start_book(start_number, end_number, store_choose_state=0, max_workers=10):
|
|||||||
logger.info(contacts)
|
logger.info(contacts)
|
||||||
with ThreadPoolExecutor(max_workers=max_workers) as executor:
|
with ThreadPoolExecutor(max_workers=max_workers) as executor:
|
||||||
for contact in contacts:
|
for contact in contacts:
|
||||||
proxy = get_proxy(contact.phone)
|
proxy = get_proxy(contact.phone, proxy_type)
|
||||||
# start the task in thread
|
# start the task in thread
|
||||||
executor.submit(CommandorPage(contact, store_type=store_choose_state).start_page, proxy)
|
executor.submit(CommandorPage(contact, store_type=store_choose_state, proxy_type=proxy_type).start_page,
|
||||||
|
proxy)
|
||||||
|
|
||||||
|
|
||||||
def get_proxy(phone_number):
|
def get_proxy(phone_number, proxy_type=0):
|
||||||
random_id_number = str(phone_number)[1:len(str(phone_number))]
|
# random_id_number = str(phone_number)[1:len(str(phone_number))]
|
||||||
proxy_username = "panleicim-res-fr-" + random_id_number
|
random_id_number = params.get_random_id_number_for_proxy()
|
||||||
|
proxy_username = params.get_proxy_name_prefix(proxy_type) + random_id_number
|
||||||
logger.info("proxy_username is " + proxy_username)
|
logger.info("proxy_username is " + proxy_username)
|
||||||
proxy = {
|
proxy = {
|
||||||
"server": params.PROXY_SERVER,
|
"server": params.PROXY_SERVER,
|
||||||
@@ -42,4 +44,4 @@ def get_proxy(phone_number):
|
|||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
# 修改联系人行,结束联系人行 第三个参数store等于0的时候是随机,传入1的时候是总店
|
# 修改联系人行,结束联系人行 第三个参数store等于0的时候是随机,传入1的时候是总店
|
||||||
start_book(16, 16, store_choose_state=0)
|
start_book(16, 16, store_choose_state=0, proxy_type=0)
|
||||||
|
|||||||
@@ -13,6 +13,14 @@ oracle_log_sender = LogSender()
|
|||||||
# proxy
|
# proxy
|
||||||
PROXY_SERVER = "http://gw.ntnt.io:5959"
|
PROXY_SERVER = "http://gw.ntnt.io:5959"
|
||||||
PROXY_PASSWORD = "94sY7zwBG13i"
|
PROXY_PASSWORD = "94sY7zwBG13i"
|
||||||
|
PROXY_NAME_PREFIX_RES = "panleicim-res-fr-"
|
||||||
|
PROXY_NAME_PREFIX_CC = "panleicim-cc-fr-"
|
||||||
|
|
||||||
|
def get_proxy_name_prefix(proxy_type = 0) -> str:
|
||||||
|
if proxy_type ==0:
|
||||||
|
return PROXY_NAME_PREFIX_RES
|
||||||
|
else:
|
||||||
|
return PROXY_NAME_PREFIX_CC
|
||||||
|
|
||||||
def get_random_id_number_for_proxy() -> str:
|
def get_random_id_number_for_proxy() -> str:
|
||||||
S = 8 # number of characters in the string.
|
S = 8 # number of characters in the string.
|
||||||
@@ -21,6 +29,7 @@ def get_random_id_number_for_proxy() -> str:
|
|||||||
print("The randomly generated string is : " + str(ran)) # print the random data
|
print("The randomly generated string is : " + str(ran)) # print the random data
|
||||||
return id_number
|
return id_number
|
||||||
|
|
||||||
|
|
||||||
DEVICES = ['iPad (gen 6)', 'iPad (gen 6) landscape', 'iPad (gen 7)', 'iPad (gen 7) landscape', 'iPad Mini',
|
DEVICES = ['iPad (gen 6)', 'iPad (gen 6) landscape', 'iPad (gen 7)', 'iPad (gen 7) landscape', 'iPad Mini',
|
||||||
'iPad Mini landscape', 'iPad Pro 11', 'iPad Pro 11 landscape', 'iPhone 6', 'iPhone 6 landscape',
|
'iPad Mini landscape', 'iPad Pro 11', 'iPad Pro 11 landscape', 'iPhone 6', 'iPhone 6 landscape',
|
||||||
'iPhone 6 Plus', 'iPhone 6 Plus landscape', 'iPhone 7', 'iPhone 7 landscape', 'iPhone 7 Plus',
|
'iPhone 6 Plus', 'iPhone 6 Plus landscape', 'iPhone 7', 'iPhone 7 landscape', 'iPhone 7 Plus',
|
||||||
|
|||||||
@@ -41,11 +41,12 @@ class Tls(threading.local):
|
|||||||
class CommandorPage:
|
class CommandorPage:
|
||||||
tls = Tls()
|
tls = Tls()
|
||||||
|
|
||||||
def __init__(self, contact: ContactPojo, store_type=0):
|
def __init__(self, contact: ContactPojo, store_type=0, proxy_type = 0):
|
||||||
self.otp_value = None
|
self.otp_value = None
|
||||||
self.logger = logging.getLogger("CommandorPage")
|
self.logger = logging.getLogger("CommandorPage")
|
||||||
self.is_finished = False
|
self.is_finished = False
|
||||||
self.contact = contact
|
self.contact = contact
|
||||||
|
self.proxy_type = proxy_type
|
||||||
# 0: random
|
# 0: random
|
||||||
# 1: faubourg
|
# 1: faubourg
|
||||||
# 2: George
|
# 2: George
|
||||||
@@ -70,7 +71,7 @@ class CommandorPage:
|
|||||||
self.termine()
|
self.termine()
|
||||||
|
|
||||||
def _run(self, e: threading.Event, proxy):
|
def _run(self, e: threading.Event, proxy):
|
||||||
print("will start browser")
|
self.logger.info("will start browser")
|
||||||
self.on_success_listener = on_success
|
self.on_success_listener = on_success
|
||||||
# reset otp_value to None
|
# reset otp_value to None
|
||||||
self.otp_value = None
|
self.otp_value = None
|
||||||
@@ -78,7 +79,7 @@ class CommandorPage:
|
|||||||
first_page = None
|
first_page = None
|
||||||
while first_page is None:
|
while first_page is None:
|
||||||
first_page = self.start_browser(proxy, self.tls.playwright, devices)
|
first_page = self.start_browser(proxy, self.tls.playwright, devices)
|
||||||
proxy_username = "panleicim-res-fr-" + params.get_random_id_number_for_proxy()
|
proxy_username = params.get_proxy_name_prefix(self.proxy_type) + params.get_random_id_number_for_proxy()
|
||||||
self.logger.info("proxy_username is " + proxy_username)
|
self.logger.info("proxy_username is " + proxy_username)
|
||||||
proxy = {
|
proxy = {
|
||||||
"server": params.PROXY_SERVER,
|
"server": params.PROXY_SERVER,
|
||||||
|
|||||||
Reference in New Issue
Block a user