add headless param
This commit is contained in:
@@ -19,7 +19,7 @@ logger.addHandler(logging.StreamHandler(stream=sys.stdout))
|
||||
|
||||
|
||||
def start_book(start_number, end_number, store_choose_state=0, max_workers=10, proxy_type=ProxyType.BRIGHT_DATA,
|
||||
mode: ModeEnum = ModeEnum.MANUAL):
|
||||
mode: ModeEnum = ModeEnum.MANUAL, headless=False):
|
||||
# read the contact, and contact the 2 objects together
|
||||
excel_reader = ExcelHelper()
|
||||
all_contacts = excel_reader.read_contacts()
|
||||
@@ -33,7 +33,7 @@ def start_book(start_number, end_number, store_choose_state=0, max_workers=10, p
|
||||
if can_send_request(contact):
|
||||
executor.submit(
|
||||
CommandorPage(contact, store_type=store_choose_state, proxy_type=proxy_type, mode=mode).start_page,
|
||||
proxy)
|
||||
proxy, headless=headless)
|
||||
else:
|
||||
logger.info("do not send request --> skip")
|
||||
|
||||
@@ -60,5 +60,5 @@ def get_proxy(proxy_type=ProxyType.BRIGHT_DATA):
|
||||
|
||||
if __name__ == '__main__':
|
||||
# 修改联系人行,结束联系人行 第三个参数store等于0的时候是随机,传入1的时候是总店
|
||||
start_book(616, 616, store_choose_state=1, mode=ModeEnum.AUTOMATIC)
|
||||
start_book(616, 616, store_choose_state=1, mode=ModeEnum.AUTOMATIC, headless=True)
|
||||
# recheck_the_captcha_error_contacts(store_type=0, mode=ModeEnum.AUTOMATIC, on_no_contact_found=lambda: None)
|
||||
|
||||
@@ -55,7 +55,7 @@ class CommandorPage:
|
||||
tls = Tls()
|
||||
|
||||
def __init__(self, contact: ContactPojo, store_type=0, proxy_type=ProxyType.BRIGHT_DATA,
|
||||
mode: ModeEnum = ModeEnum.MANUAL):
|
||||
mode: ModeEnum = ModeEnum.MANUAL, headless=False):
|
||||
self.otp_value = None
|
||||
self.logger = logging.getLogger("约会页面:" + str(contact.phone))
|
||||
self.is_finished = False
|
||||
@@ -64,6 +64,7 @@ class CommandorPage:
|
||||
self.is_event_sent = False
|
||||
self.is_captcha_in_error = False
|
||||
self.is_filling_fields = False
|
||||
self.headless = headless
|
||||
self.appointment_mode = mode
|
||||
# 0: random
|
||||
# 1: faubourg
|
||||
@@ -122,7 +123,7 @@ class CommandorPage:
|
||||
|
||||
def start_browser(self, proxy, pwright, device) -> Union[str, None]:
|
||||
try:
|
||||
self.browser = pwright.webkit.launch(headless=False, timeout=PAGE_TIMEOUT, proxy=proxy)
|
||||
self.browser = pwright.webkit.launch(headless=self.headless, timeout=PAGE_TIMEOUT, proxy=proxy)
|
||||
self.logger.info("模拟设备: " + device)
|
||||
simulated_mobile = pwright.devices[device]
|
||||
context = self.browser.new_context(**simulated_mobile, locale='fr-FR')
|
||||
|
||||
Reference in New Issue
Block a user