Skip to content

Commit

Permalink
Merge pull request NaiboWang#360 from touero/master
Browse files Browse the repository at this point in the history
Fixing get data before if case in preprocess event loop
  • Loading branch information
NaiboWang committed Apr 27, 2024
2 parents a8e77b5 + 52702d4 commit c272e5d
Showing 1 changed file with 14 additions and 17 deletions.
31 changes: 14 additions & 17 deletions ExecuteStage/easyspider_executestage.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,24 +234,20 @@ def __init__(self, browser_t, id, service, version, event, saveName, config, opt

# 检测如果没有复杂的操作,优化提取数据流程
def preprocess(self):
for node in self.procedure:
try:
iframe = node["parameters"]["iframe"]
except:
node["parameters"]["iframe"] = False
for index_node, node in enumerate(self.procedure):
parameters = node["parameters"]
iframe = parameters.get('iframe')
parameters["iframe"] = False if not iframe else ...
if parameters.get("xpath"):
parameters["xpath"] = lowercase_tags_in_xpath(parameters["xpath"])

if parameters.get("waitElementIframeIndex"):
parameters["waitElementIframeIndex"] = int(parameters["waitElementIframeIndex"])
else:
parameters["waitElement"] = ""
parameters["waitElementTime"] = 10
parameters["waitElementIframeIndex"] = 0

try:
node["parameters"]["xpath"] = lowercase_tags_in_xpath(
node["parameters"]["xpath"])
except:
pass
try:
node["parameters"]["waitElementIframeIndex"] = int(
node["parameters"]["waitElementIframeIndex"])
except:
node["parameters"]["waitElement"] = ""
node["parameters"]["waitElementTime"] = 10
node["parameters"]["waitElementIframeIndex"] = 0
if node["option"] == 1: # 打开网页操作
try:
cookies = node["parameters"]["cookies"]
Expand Down Expand Up @@ -409,6 +405,7 @@ def preprocess(self):
"nodeType": param["nodeType"],
"default": param["default"],
})
self.procedure[index_node]["parameters"] = parameters
self.print_and_log("预处理完成|Preprocess completed")

def readFromExcel(self):
Expand Down

0 comments on commit c272e5d

Please sign in to comment.