Spaces:
Paused
Paused
update
Browse files
toolbox/douyin_selenium/tasks/bless_bag_collector.py
CHANGED
|
@@ -78,7 +78,11 @@ class BlessBagCollector(object):
|
|
| 78 |
|
| 79 |
def get_bless_bag_element(self):
|
| 80 |
xpath = "//div[@id='ShortTouchLayout']//x-text[@class='count_down_web']"
|
| 81 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 82 |
|
| 83 |
def get_bless_bag_card_button_element(self):
|
| 84 |
xpath = '//div[@id="lottery_close_cotainer"]//div[contains(text(), "一键发评论参与福袋") or contains(text(), "分享直播间") or contains(text(), "加入粉丝团(1钻)") or contains(text(), "已参与") or contains(text(), "知道了")]'
|
|
@@ -94,7 +98,11 @@ class BlessBagCollector(object):
|
|
| 94 |
|
| 95 |
def get_bless_bag_countdown_element(self):
|
| 96 |
xpath = "//div[@id='ShortTouchLayout']//div/x-view//x-text[@class='count_down_web']"
|
| 97 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 98 |
|
| 99 |
def get_bless_bag_card_close_element(self):
|
| 100 |
xpath = "//div[@id='lottery_close_cotainer']/div/div/div[2]"
|
|
@@ -113,7 +121,7 @@ class BlessBagCollector(object):
|
|
| 113 |
if bless_bag_element is None:
|
| 114 |
return False
|
| 115 |
logger.info(f"{self.flag}发现福袋.")
|
| 116 |
-
if random.random() < self.bless_bag_join_rate:
|
| 117 |
logger.info(f"{self.flag}放弃福袋.")
|
| 118 |
self.sleep_by_bless_bag_countdown()
|
| 119 |
return False
|
|
|
|
| 78 |
|
| 79 |
def get_bless_bag_element(self):
|
| 80 |
xpath = "//div[@id='ShortTouchLayout']//x-text[@class='count_down_web']"
|
| 81 |
+
element = self.get_element_by_xpath(xpath)
|
| 82 |
+
if element is None:
|
| 83 |
+
xpath = "//div[@id='ShortTouchLayout']/div/div/div/div/div"
|
| 84 |
+
element = self.get_element_by_xpath(xpath)
|
| 85 |
+
return element
|
| 86 |
|
| 87 |
def get_bless_bag_card_button_element(self):
|
| 88 |
xpath = '//div[@id="lottery_close_cotainer"]//div[contains(text(), "一键发评论参与福袋") or contains(text(), "分享直播间") or contains(text(), "加入粉丝团(1钻)") or contains(text(), "已参与") or contains(text(), "知道了")]'
|
|
|
|
| 98 |
|
| 99 |
def get_bless_bag_countdown_element(self):
|
| 100 |
xpath = "//div[@id='ShortTouchLayout']//div/x-view//x-text[@class='count_down_web']"
|
| 101 |
+
element = self.get_element_by_xpath(xpath)
|
| 102 |
+
if element is None:
|
| 103 |
+
xpath = "//div[@id='ShortTouchLayout']/div/div/div/div/div"
|
| 104 |
+
element = self.get_element_by_xpath(xpath)
|
| 105 |
+
return element
|
| 106 |
|
| 107 |
def get_bless_bag_card_close_element(self):
|
| 108 |
xpath = "//div[@id='lottery_close_cotainer']/div/div/div[2]"
|
|
|
|
| 121 |
if bless_bag_element is None:
|
| 122 |
return False
|
| 123 |
logger.info(f"{self.flag}发现福袋.")
|
| 124 |
+
if random.random() < (1 - self.bless_bag_join_rate):
|
| 125 |
logger.info(f"{self.flag}放弃福袋.")
|
| 126 |
self.sleep_by_bless_bag_countdown()
|
| 127 |
return False
|