Skip to content

Commit 145c766

Browse files
committed
单个单元格限制提醒
1 parent 528ae7a commit 145c766

File tree

4 files changed

+58
-30
lines changed

4 files changed

+58
-30
lines changed

ElectronJS/src/taskGrid/logic.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,24 @@ ws.onmessage = function(evt) {
3838
}
3939
};
4040

41+
function changeOutputFormat(para){
42+
try{
43+
for(let i=0;i<para["parameters"].length;i++) {
44+
let exampleValue = para["parameters"][i]["exampleValues"][0]["value"];
45+
let len = exampleValue.length;
46+
if (len > 20000) {
47+
if($("#outputFormat").val() == "xlsx") {
48+
$("#outputFormat").val("csv"); //如果有一个参数的示例值长度超过20000,就默认输出为csv
49+
showInfo(LANG("示例值长度超过16000,超出Excel单个单元格存储限制,已自动切换保存为csv格式。", "The length of the example value exceeds 16000, and the csv save format has been automatically switched."));
50+
}
51+
break;
52+
}
53+
}
54+
} catch(e){
55+
console.log(e);
56+
}
57+
}
58+
4159
function changeGetDataParameters(msg, i) {
4260
msg["parameters"][i]["default"] = ""; //找不到元素时候的默认值
4361
msg["parameters"][i]["paraType"] = "text"; //参数类型
@@ -82,16 +100,19 @@ function handleAddElement(msg) {
82100
changeGetDataParameters(msg, i);
83101
app._data["nowNode"]["parameters"]["paras"].push(msg["parameters"][i]);
84102
}
103+
changeOutputFormat(msg);
85104
app._data.paras.parameters = app._data["nowNode"]["parameters"]["paras"];
86105
setTimeout(function(){$("#app > div.elements > div.toolkitcontain > table.toolkittb4 > tbody > tr:last-child")[0].scrollIntoView(false); //滚动到底部
87106
}, 200);
88107
} else {
89108
addElement(3, msg);
109+
changeOutputFormat(msg);
90110
}
91111
notifyParameterNum(msg["parameters"].length); //通知浏览器端参数的个数变化
92112
} else if (msg["type"] == "multiCollectWithPattern") {
93113
addElement(8, msg);
94114
addElement(3, msg);
115+
changeOutputFormat(msg);
95116
notifyParameterNum(msg["parameters"].length); //通知浏览器端参数的个数变化
96117
} else if(msg["type"] == "GetCookies"){
97118
for(let node of nodeList){

ElectronJS/tasks/202.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

ExecuteStage/.vscode/launch.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"justMyCode": false,
1313
// "args": ["--id", "[7]", "--read_type", "remote", "--headless", "0"]
1414
// "args": ["--id", "[9]", "--read_type", "remote", "--headless", "0", "--saved_file_name", "YOUTUBE"]
15-
"args": ["--id", "[16]", "--headless", "0", "--user_data", "1", "--keyboard", "0"]
15+
"args": ["--id", "[85]", "--headless", "0", "--user_data", "1", "--keyboard", "0"]
1616
}
1717
]
1818
}

ExecuteStage/utils.py

Lines changed: 35 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -101,34 +101,39 @@ def download_image(browser, url, save_directory):
101101
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36'
102102
}
103103
if is_valid_url(url):
104-
# 发送 GET 请求获取图片数据
105-
response = requests.get(url, headers=headers)
106-
107-
# 检查响应状态码是否为成功状态
108-
if response.status_code == requests.codes.ok:
109-
# 提取文件名
110-
file_name = url.split('/')[-1].split("?")[0]
111-
112-
# 生成唯一的新文件名
113-
new_file_name = file_name + '_' + \
114-
str(uuid.uuid4()) + '_' + file_name
115-
116-
# 构建保存路径
117-
save_path = os.path.join(save_directory, new_file_name)
118-
119-
# 保存图片到本地
120-
with open(save_path, 'wb') as file:
121-
file.write(response.content)
122-
123-
browser.print_and_log("图片已成功下载到:", save_path)
124-
browser.print_and_log("The image has been successfully downloaded to:", save_path)
125-
else:
126-
browser.print_and_log("下载图片失败,请检查此图片链接是否有效:", url)
127-
browser.print_and_log(
128-
"Failed to download image, please check if this image link is valid:", url)
104+
try:
105+
# 发送 GET 请求获取图片数据
106+
response = requests.get(url, headers=headers)
107+
108+
# 检查响应状态码是否为成功状态
109+
if response.status_code == requests.codes.ok:
110+
# 提取文件名
111+
file_name = url.split('/')[-1].split("?")[0]
112+
113+
# 生成唯一的新文件名
114+
new_file_name = file_name + '_' + \
115+
str(uuid.uuid4()) + '_' + file_name
116+
117+
# 构建保存路径
118+
save_path = os.path.join(save_directory, new_file_name)
119+
120+
# 保存图片到本地
121+
with open(save_path, 'wb') as file:
122+
file.write(response.content)
123+
124+
browser.print_and_log("图片已成功下载到:", save_path)
125+
browser.print_and_log(
126+
"The image has been successfully downloaded to:", save_path)
127+
else:
128+
browser.print_and_log("下载图片失败,请检查此图片链接是否有效:", url)
129+
browser.print_and_log(
130+
"Failed to download image, please check if this image link is valid:", url)
131+
except Exception as e:
132+
browser.print_and_log("下载图片失败|Error downloading image: ", e)
129133
else:
130134
browser.print_and_log("下载图片失败,请检查此图片链接是否有效:", url)
131-
browser.print_and_log("Failed to download image, please check if this image link is valid:", url)
135+
browser.print_and_log(
136+
"Failed to download image, please check if this image link is valid:", url)
132137

133138

134139
def get_output_code(output):
@@ -201,9 +206,9 @@ def write_to_json(file_name, data, types, record, keys):
201206
except:
202207
line[i] = 0.0
203208
if record[i]:
204-
to_write.update({keys[i]: line[i]})
209+
to_write.update({keys[i]: line[i]})
205210
data_to_write.append(to_write)
206-
211+
207212
try:
208213
# read data from JSON
209214
with open(file_name, 'r', encoding='utf-8') as f:
@@ -212,11 +217,12 @@ def write_to_json(file_name, data, types, record, keys):
212217
json_data = []
213218

214219
json_data.extend(data_to_write)
215-
220+
216221
# write data to JSON
217222
with open(file_name, 'w', encoding='utf-8') as f:
218223
json.dump(json_data, f, ensure_ascii=False)
219224

225+
220226
def write_to_excel(file_name, data, types, record):
221227
first = False
222228
if os.path.exists(file_name):

0 commit comments

Comments
 (0)