Skip to content

Commit 5df5304

Browse files
Merge branch 'develop' into discriptionbox
2 parents 7d652f4 + c6a1d82 commit 5df5304

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1806
-309
lines changed

maxun-core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "maxun-core",
3-
"version": "0.0.16",
3+
"version": "0.0.17",
44
"description": "Core package for Maxun, responsible for data extraction",
55
"main": "build/index.js",
66
"typings": "build/index.d.ts",

maxun-core/src/browserSide/scraper.js

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -725,6 +725,30 @@ function scrapableHeuristics(maxCountPerPage = 50, minArea = 20000, scrolls = 3,
725725
});
726726
}
727727

728+
function tryFallbackSelector(rootElement, originalSelector) {
729+
let element = queryElement(rootElement, originalSelector);
730+
731+
if (!element && originalSelector.includes('nth-child')) {
732+
const match = originalSelector.match(/nth-child\((\d+)\)/);
733+
if (match) {
734+
const position = parseInt(match[1], 10);
735+
736+
for (let i = position - 1; i >= 1; i--) {
737+
const fallbackSelector = originalSelector.replace(/nth-child\(\d+\)/, `nth-child(${i})`);
738+
element = queryElement(rootElement, fallbackSelector);
739+
if (element) break;
740+
}
741+
742+
if (!element) {
743+
const baseSelector = originalSelector.replace(/\:nth-child\(\d+\)/, '');
744+
element = queryElement(rootElement, baseSelector);
745+
}
746+
}
747+
}
748+
749+
return element;
750+
}
751+
728752
// Main scraping logic with context support
729753
let containers = queryElementAll(document, listSelector);
730754
containers = Array.from(containers);
@@ -902,7 +926,7 @@ function scrapableHeuristics(maxCountPerPage = 50, minArea = 20000, scrolls = 3,
902926
for (const [label, { selector, attribute }] of Object.entries(nonTableFields)) {
903927
// Get the last part of the selector after any context delimiter
904928
const relativeSelector = selector.split(/(?:>>|:>>)/).slice(-1)[0];
905-
const element = queryElement(container, relativeSelector);
929+
const element = tryFallbackSelector(container, relativeSelector);
906930

907931
if (element) {
908932
record[label] = extractValue(element, attribute);

maxun-core/src/interpret.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -825,6 +825,7 @@ export default class Interpreter extends EventEmitter {
825825
button.click()
826826
]);
827827
debugLog("Navigation successful after regular click");
828+
await page.waitForTimeout(2000);
828829
paginationSuccess = true;
829830
} catch (navError) {
830831
debugLog("Regular click with navigation failed, trying dispatch event with navigation");
@@ -839,6 +840,7 @@ export default class Interpreter extends EventEmitter {
839840
button.dispatchEvent('click')
840841
]);
841842
debugLog("Navigation successful after dispatch event");
843+
await page.waitForTimeout(2000);
842844
paginationSuccess = true;
843845
} catch (dispatchNavError) {
844846
try {

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "maxun",
3-
"version": "0.0.14",
3+
"version": "0.0.15",
44
"author": "Maxun",
55
"license": "AGPL-3.0-or-later",
66
"dependencies": {
@@ -50,7 +50,7 @@
5050
"lodash": "^4.17.21",
5151
"loglevel": "^1.8.0",
5252
"loglevel-plugin-remote": "^0.6.8",
53-
"maxun-core": "^0.0.16",
53+
"maxun-core": "^0.0.17",
5454
"minio": "^8.0.1",
5555
"moment-timezone": "^0.5.45",
5656
"node-cron": "^3.0.3",

public/locales/de.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@
163163
},
164164
"default": {
165165
"title": "Welche Daten möchten Sie extrahieren?",
166-
"description": "Ein Roboter ist darauf ausgelegt, eine Aktion nach der anderen auszuführen. Sie können eine der folgenden Optionen wählen."
166+
"description": "Ein Roboter kann eine oder mehrere Aktionen ausführen. Wählen Sie aus den unten aufgeführten Optionen."
167167
},
168168
"list_stages": {
169169
"initial": "Wählen Sie die Liste aus, die Sie extrahieren möchten, zusammen mit den darin enthaltenen Texten",

public/locales/en.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@
170170
},
171171
"default": {
172172
"title": "What data do you want to extract?",
173-
"description": "A robot is designed to perform one action at a time. You can choose any of the options below."
173+
"description": "A robot can perform one or multiple actions. Choose from the options listed below."
174174
},
175175
"list_stages": {
176176
"initial": "Select the list you want to extract along with the texts inside it",

public/locales/es.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@
164164
},
165165
"default": {
166166
"title": "¿Qué datos desea extraer?",
167-
"description": "Un robot está diseñado para realizar una acción a la vez. Puede elegir cualquiera de las siguientes opciones."
167+
"description": "Un robot puede realizar una o varias acciones. Elija entre las opciones que aparecen a continuación."
168168
},
169169
"list_stages": {
170170
"initial": "Seleccione la lista que desea extraer junto con los textos que contiene",

public/locales/ja.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@
164164
},
165165
"default": {
166166
"title": "どのデータを抽出しますか?",
167-
"description": "ロボットは一度に1つのアクションを実行するように設計されています。以下のオプションから選択できます"
167+
"description": "ロボットは1つまたは複数のアクションを実行できます。以下のオプションから選択してください"
168168
},
169169
"list_stages": {
170170
"initial": "抽出したいリストとその中のテキストを選択してください",

public/locales/zh.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@
164164
},
165165
"default": {
166166
"title": "您想提取什么数据?",
167-
"description": "机器人设计为一次执行一个操作。您可以选择以下任何选项"
167+
"description": "机器人可以执行一个或多个动作。请从以下选项中选择"
168168
},
169169
"list_stages": {
170170
"initial": "选择要提取的列表及其中的文本",

public/svg/webhook.svg

Lines changed: 14 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)