octoparse-cli 0.1.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +271 -0
- package/RUNTIME_SECURITY_NOTICE.txt +41 -0
- package/SECURITY.md +24 -0
- package/dist/cli/args.js +34 -0
- package/dist/cli/help.js +214 -0
- package/dist/cli/output.js +39 -0
- package/dist/commands/auth.js +283 -0
- package/dist/commands/capabilities.js +118 -0
- package/dist/commands/cloud.js +241 -0
- package/dist/commands/data.js +220 -0
- package/dist/commands/doctor.js +73 -0
- package/dist/commands/env.js +63 -0
- package/dist/commands/local.js +251 -0
- package/dist/commands/run.js +622 -0
- package/dist/commands/runs.js +171 -0
- package/dist/commands/task.js +101 -0
- package/dist/index.js +133 -0
- package/dist/runtime/account-capabilities.js +71 -0
- package/dist/runtime/api-client.js +290 -0
- package/dist/runtime/artifacts.js +33 -0
- package/dist/runtime/auth.js +94 -0
- package/dist/runtime/bridge-hub.js +173 -0
- package/dist/runtime/client-headers.js +23 -0
- package/dist/runtime/cloud-data.js +75 -0
- package/dist/runtime/config.js +48 -0
- package/dist/runtime/data-exporter.js +267 -0
- package/dist/runtime/engine-host.js +449 -0
- package/dist/runtime/local-runs.js +92 -0
- package/dist/runtime/naming.js +13 -0
- package/dist/runtime/run-control.js +363 -0
- package/dist/runtime/run-services.js +380 -0
- package/dist/runtime/security-notice.js +78 -0
- package/dist/runtime/task-definition-provider.js +282 -0
- package/dist/types.js +4 -0
- package/examples/minimal-task.json +6 -0
- package/examples/navigate-example-task.json +6 -0
- package/node_modules/@octopus/bpmn/index.js +3 -0
- package/node_modules/@octopus/bpmn/lib/Context.js +245 -0
- package/node_modules/@octopus/bpmn/lib/Definition.js +258 -0
- package/node_modules/@octopus/bpmn/lib/Engine.js +275 -0
- package/node_modules/@octopus/bpmn/lib/PrematureStopError.js +7 -0
- package/node_modules/@octopus/bpmn/lib/activities/Activity.js +202 -0
- package/node_modules/@octopus/bpmn/lib/activities/BaseProcess.js +308 -0
- package/node_modules/@octopus/bpmn/lib/activities/BaseTask.js +145 -0
- package/node_modules/@octopus/bpmn/lib/activities/BoundaryEvent.js +12 -0
- package/node_modules/@octopus/bpmn/lib/activities/Dummy.js +10 -0
- package/node_modules/@octopus/bpmn/lib/activities/EventDefinition.js +99 -0
- package/node_modules/@octopus/bpmn/lib/activities/Flow.js +52 -0
- package/node_modules/@octopus/bpmn/lib/activities/Form.js +67 -0
- package/node_modules/@octopus/bpmn/lib/activities/InputOutput.js +53 -0
- package/node_modules/@octopus/bpmn/lib/activities/IntermediateCatchEvent.js +12 -0
- package/node_modules/@octopus/bpmn/lib/activities/MessageFlow.js +19 -0
- package/node_modules/@octopus/bpmn/lib/activities/MultiInstanceLoopCharacteristics.js +160 -0
- package/node_modules/@octopus/bpmn/lib/activities/Properties.js +27 -0
- package/node_modules/@octopus/bpmn/lib/activities/SequenceFlow.js +56 -0
- package/node_modules/@octopus/bpmn/lib/activities/ServiceConnector.js +71 -0
- package/node_modules/@octopus/bpmn/lib/context-helper.js +198 -0
- package/node_modules/@octopus/bpmn/lib/events/EndEvent.js +22 -0
- package/node_modules/@octopus/bpmn/lib/events/ErrorEvent.js +41 -0
- package/node_modules/@octopus/bpmn/lib/events/MessageEvent.js +19 -0
- package/node_modules/@octopus/bpmn/lib/events/StartEvent.js +55 -0
- package/node_modules/@octopus/bpmn/lib/events/TimerEvent.js +75 -0
- package/node_modules/@octopus/bpmn/lib/expressions.js +41 -0
- package/node_modules/@octopus/bpmn/lib/gateways/ExclusiveGateway.js +86 -0
- package/node_modules/@octopus/bpmn/lib/gateways/InclusiveGateway.js +56 -0
- package/node_modules/@octopus/bpmn/lib/gateways/ParallelGateway.js +195 -0
- package/node_modules/@octopus/bpmn/lib/getPropertyValue.js +83 -0
- package/node_modules/@octopus/bpmn/lib/index.js +6 -0
- package/node_modules/@octopus/bpmn/lib/mapper.js +55 -0
- package/node_modules/@octopus/bpmn/lib/parameter.js +119 -0
- package/node_modules/@octopus/bpmn/lib/script-helper.js +45 -0
- package/node_modules/@octopus/bpmn/lib/tasks/ManualTask.js +31 -0
- package/node_modules/@octopus/bpmn/lib/tasks/ReceiveTask.js +31 -0
- package/node_modules/@octopus/bpmn/lib/tasks/ScriptTask.js +35 -0
- package/node_modules/@octopus/bpmn/lib/tasks/SendTask.js +16 -0
- package/node_modules/@octopus/bpmn/lib/tasks/ServiceTask.js +68 -0
- package/node_modules/@octopus/bpmn/lib/tasks/SubProcess.js +17 -0
- package/node_modules/@octopus/bpmn/lib/tasks/Task.js +16 -0
- package/node_modules/@octopus/bpmn/lib/tasks/UserTask.js +47 -0
- package/node_modules/@octopus/bpmn/lib/transformer.js +13 -0
- package/node_modules/@octopus/bpmn/lib/validation.js +111 -0
- package/node_modules/@octopus/bpmn/package.json +17 -0
- package/node_modules/@octopus/bpmn/types/bpmn.d.ts +85 -0
- package/node_modules/@octopus/engine/README.md +370 -0
- package/node_modules/@octopus/engine/dist/actions/BackPreWebPageAction.d.ts +4 -0
- package/node_modules/@octopus/engine/dist/actions/BackPreWebPageAction.js +1 -0
- package/node_modules/@octopus/engine/dist/actions/BaseAction.d.ts +339 -0
- package/node_modules/@octopus/engine/dist/actions/BaseAction.js +1559 -0
- package/node_modules/@octopus/engine/dist/actions/BranchAction.d.ts +9 -0
- package/node_modules/@octopus/engine/dist/actions/BranchAction.js +1 -0
- package/node_modules/@octopus/engine/dist/actions/ClickAction.d.ts +22 -0
- package/node_modules/@octopus/engine/dist/actions/ClickAction.js +1 -0
- package/node_modules/@octopus/engine/dist/actions/ConditionAction.d.ts +4 -0
- package/node_modules/@octopus/engine/dist/actions/ConditionAction.js +1 -0
- package/node_modules/@octopus/engine/dist/actions/EmptyAction.d.ts +4 -0
- package/node_modules/@octopus/engine/dist/actions/EmptyAction.js +12 -0
- package/node_modules/@octopus/engine/dist/actions/EnterCaptchaAction.d.ts +28 -0
- package/node_modules/@octopus/engine/dist/actions/EnterCaptchaAction.js +1 -0
- package/node_modules/@octopus/engine/dist/actions/EnterTextAction.d.ts +20 -0
- package/node_modules/@octopus/engine/dist/actions/EnterTextAction.js +1 -0
- package/node_modules/@octopus/engine/dist/actions/ExtractDataAction.d.ts +40 -0
- package/node_modules/@octopus/engine/dist/actions/ExtractDataAction.js +1 -0
- package/node_modules/@octopus/engine/dist/actions/LoopAction.d.ts +41 -0
- package/node_modules/@octopus/engine/dist/actions/LoopAction.js +526 -0
- package/node_modules/@octopus/engine/dist/actions/LoopStartAction.d.ts +47 -0
- package/node_modules/@octopus/engine/dist/actions/LoopStartAction.js +607 -0
- package/node_modules/@octopus/engine/dist/actions/MouseOverAction.d.ts +8 -0
- package/node_modules/@octopus/engine/dist/actions/MouseOverAction.js +34 -0
- package/node_modules/@octopus/engine/dist/actions/NavigateAction.d.ts +38 -0
- package/node_modules/@octopus/engine/dist/actions/NavigateAction.js +535 -0
- package/node_modules/@octopus/engine/dist/actions/SwitchComboAction.d.ts +13 -0
- package/node_modules/@octopus/engine/dist/actions/SwitchComboAction.js +69 -0
- package/node_modules/@octopus/engine/dist/browser.d.ts +17 -0
- package/node_modules/@octopus/engine/dist/browser.js +157 -0
- package/node_modules/@octopus/engine/dist/browserProxy.d.ts +90 -0
- package/node_modules/@octopus/engine/dist/browserProxy.js +1 -0
- package/node_modules/@octopus/engine/dist/configs/BaseConfig.d.ts +20 -0
- package/node_modules/@octopus/engine/dist/configs/BaseConfig.js +88 -0
- package/node_modules/@octopus/engine/dist/configs/BranchConfig.d.ts +7 -0
- package/node_modules/@octopus/engine/dist/configs/BranchConfig.js +1 -0
- package/node_modules/@octopus/engine/dist/configs/ClickConfig.d.ts +36 -0
- package/node_modules/@octopus/engine/dist/configs/ClickConfig.js +65 -0
- package/node_modules/@octopus/engine/dist/configs/EnterCaptchaConfig.d.ts +19 -0
- package/node_modules/@octopus/engine/dist/configs/EnterCaptchaConfig.js +25 -0
- package/node_modules/@octopus/engine/dist/configs/EnterTextConfig.d.ts +24 -0
- package/node_modules/@octopus/engine/dist/configs/EnterTextConfig.js +36 -0
- package/node_modules/@octopus/engine/dist/configs/ExtractDataConfig.d.ts +12 -0
- package/node_modules/@octopus/engine/dist/configs/ExtractDataConfig.js +1 -0
- package/node_modules/@octopus/engine/dist/configs/LoopConfig.d.ts +25 -0
- package/node_modules/@octopus/engine/dist/configs/LoopConfig.js +40 -0
- package/node_modules/@octopus/engine/dist/configs/LoopStartConfig.d.ts +4 -0
- package/node_modules/@octopus/engine/dist/configs/LoopStartConfig.js +12 -0
- package/node_modules/@octopus/engine/dist/configs/MouseOverConfig.d.ts +8 -0
- package/node_modules/@octopus/engine/dist/configs/MouseOverConfig.js +15 -0
- package/node_modules/@octopus/engine/dist/configs/NavigateConfig.d.ts +41 -0
- package/node_modules/@octopus/engine/dist/configs/NavigateConfig.js +121 -0
- package/node_modules/@octopus/engine/dist/configs/SwitchComboConfig.d.ts +8 -0
- package/node_modules/@octopus/engine/dist/configs/SwitchComboConfig.js +15 -0
- package/node_modules/@octopus/engine/dist/enums/index.d.ts +419 -0
- package/node_modules/@octopus/engine/dist/enums/index.js +314 -0
- package/node_modules/@octopus/engine/dist/extension/BrowserWebSocketTransport-D_zAGZMQ.js +1 -0
- package/node_modules/@octopus/engine/dist/extension/LaunchOptions-DxvePrV4.js +6 -0
- package/node_modules/@octopus/engine/dist/extension/NodeWebSocketTransport-BTgRVB7Z.js +6 -0
- package/node_modules/@octopus/engine/dist/extension/background.js +396 -0
- package/node_modules/@octopus/engine/dist/extension/bidi-C_GIZ8Uz.js +131 -0
- package/node_modules/@octopus/engine/dist/extension/manifest.json +27 -0
- package/node_modules/@octopus/engine/dist/extension/src/content/anti-detection.js +1 -0
- package/node_modules/@octopus/engine/dist/extension-bridge/BaseExtensionBridge.d.ts +21 -0
- package/node_modules/@octopus/engine/dist/extension-bridge/BaseExtensionBridge.js +117 -0
- package/node_modules/@octopus/engine/dist/extension-bridge/SessionExtensionBridge.d.ts +17 -0
- package/node_modules/@octopus/engine/dist/extension-bridge/SessionExtensionBridge.js +29 -0
- package/node_modules/@octopus/engine/dist/extension-bridge/index.d.ts +2 -0
- package/node_modules/@octopus/engine/dist/extension-bridge/index.js +5 -0
- package/node_modules/@octopus/engine/dist/extension-bridge/types.d.ts +159 -0
- package/node_modules/@octopus/engine/dist/extension-bridge/types.js +5 -0
- package/node_modules/@octopus/engine/dist/extensions/ublock-origin/uBlock0.chromium.tar.xz +0 -0
- package/node_modules/@octopus/engine/dist/extensions/ublock-origin-lite/uBOLite.chromium.tar.xz +0 -0
- package/node_modules/@octopus/engine/dist/index.d.ts +169 -0
- package/node_modules/@octopus/engine/dist/index.js +1 -0
- package/node_modules/@octopus/engine/dist/models/actionItem.d.ts +16 -0
- package/node_modules/@octopus/engine/dist/models/actionItem.js +15 -0
- package/node_modules/@octopus/engine/dist/models/conditionCheckArgs.d.ts +11 -0
- package/node_modules/@octopus/engine/dist/models/conditionCheckArgs.js +11 -0
- package/node_modules/@octopus/engine/dist/models/customizeCookie.d.ts +14 -0
- package/node_modules/@octopus/engine/dist/models/customizeCookie.js +6 -0
- package/node_modules/@octopus/engine/dist/models/downloadFileConfig.d.ts +17 -0
- package/node_modules/@octopus/engine/dist/models/downloadFileConfig.js +26 -0
- package/node_modules/@octopus/engine/dist/models/elementNotFoundArgs.d.ts +8 -0
- package/node_modules/@octopus/engine/dist/models/elementNotFoundArgs.js +12 -0
- package/node_modules/@octopus/engine/dist/models/elementNotFoundError.d.ts +2 -0
- package/node_modules/@octopus/engine/dist/models/elementNotFoundError.js +6 -0
- package/node_modules/@octopus/engine/dist/models/extractItem.d.ts +37 -0
- package/node_modules/@octopus/engine/dist/models/extractItem.js +35 -0
- package/node_modules/@octopus/engine/dist/models/extractTemplate.d.ts +11 -0
- package/node_modules/@octopus/engine/dist/models/extractTemplate.js +48 -0
- package/node_modules/@octopus/engine/dist/models/extractTextItem.d.ts +10 -0
- package/node_modules/@octopus/engine/dist/models/extractTextItem.js +17 -0
- package/node_modules/@octopus/engine/dist/models/globalConfig.d.ts +5 -0
- package/node_modules/@octopus/engine/dist/models/globalConfig.js +1 -0
- package/node_modules/@octopus/engine/dist/models/httpHeader.d.ts +4 -0
- package/node_modules/@octopus/engine/dist/models/httpHeader.js +10 -0
- package/node_modules/@octopus/engine/dist/models/operation.d.ts +27 -0
- package/node_modules/@octopus/engine/dist/models/operation.js +242 -0
- package/node_modules/@octopus/engine/dist/models/retryCondition.d.ts +7 -0
- package/node_modules/@octopus/engine/dist/models/retryCondition.js +10 -0
- package/node_modules/@octopus/engine/dist/models/task.d.ts +89 -0
- package/node_modules/@octopus/engine/dist/models/task.js +120 -0
- package/node_modules/@octopus/engine/dist/models/trigger.d.ts +66 -0
- package/node_modules/@octopus/engine/dist/models/trigger.js +117 -0
- package/node_modules/@octopus/engine/dist/package.json +26 -0
- package/node_modules/@octopus/engine/dist/public-types.d.ts +13 -0
- package/node_modules/@octopus/engine/dist/public-types.js +2 -0
- package/node_modules/@octopus/engine/dist/settings.d.ts +41 -0
- package/node_modules/@octopus/engine/dist/settings.js +20 -0
- package/node_modules/@octopus/engine/dist/solvers/captcha/ClickCaptchaSolver.d.ts +6 -0
- package/node_modules/@octopus/engine/dist/solvers/captcha/ClickCaptchaSolver.js +1 -0
- package/node_modules/@octopus/engine/dist/solvers/captcha/HCaptchaSolver.d.ts +4 -0
- package/node_modules/@octopus/engine/dist/solvers/captcha/HCaptchaSolver.js +73 -0
- package/node_modules/@octopus/engine/dist/solvers/captcha/ImageCaptchaSolver.d.ts +2 -0
- package/node_modules/@octopus/engine/dist/solvers/captcha/ImageCaptchaSolver.js +74 -0
- package/node_modules/@octopus/engine/dist/solvers/captcha/RecaptchaSolver.d.ts +9 -0
- package/node_modules/@octopus/engine/dist/solvers/captcha/RecaptchaSolver.js +371 -0
- package/node_modules/@octopus/engine/dist/solvers/captcha/SliderCaptchaSolver.d.ts +6 -0
- package/node_modules/@octopus/engine/dist/solvers/captcha/SliderCaptchaSolver.js +184 -0
- package/node_modules/@octopus/engine/dist/solvers/captcha/SlidingTrajectory.d.ts +50 -0
- package/node_modules/@octopus/engine/dist/solvers/captcha/SlidingTrajectory.js +125 -0
- package/node_modules/@octopus/engine/dist/solvers/captcha/types.d.ts +68 -0
- package/node_modules/@octopus/engine/dist/solvers/captcha/types.js +34 -0
- package/node_modules/@octopus/engine/dist/solvers/captcha/utils.d.ts +2 -0
- package/node_modules/@octopus/engine/dist/solvers/captcha/utils.js +15 -0
- package/node_modules/@octopus/engine/dist/translator/actionFactory.d.ts +6 -0
- package/node_modules/@octopus/engine/dist/translator/actionFactory.js +1 -0
- package/node_modules/@octopus/engine/dist/translator/activityTypeEnum.d.ts +22 -0
- package/node_modules/@octopus/engine/dist/translator/activityTypeEnum.js +1 -0
- package/node_modules/@octopus/engine/dist/translator/backPreWebPageAction.d.ts +5 -0
- package/node_modules/@octopus/engine/dist/translator/backPreWebPageAction.js +1 -0
- package/node_modules/@octopus/engine/dist/translator/baseAction.d.ts +31 -0
- package/node_modules/@octopus/engine/dist/translator/baseAction.js +1 -0
- package/node_modules/@octopus/engine/dist/translator/breakActivity.d.ts +5 -0
- package/node_modules/@octopus/engine/dist/translator/breakActivity.js +1 -0
- package/node_modules/@octopus/engine/dist/translator/clickAction.d.ts +5 -0
- package/node_modules/@octopus/engine/dist/translator/clickAction.js +1 -0
- package/node_modules/@octopus/engine/dist/translator/completeWF.d.ts +5 -0
- package/node_modules/@octopus/engine/dist/translator/completeWF.js +1 -0
- package/node_modules/@octopus/engine/dist/translator/conditionAction.d.ts +6 -0
- package/node_modules/@octopus/engine/dist/translator/conditionAction.js +1 -0
- package/node_modules/@octopus/engine/dist/translator/emptyAction.d.ts +5 -0
- package/node_modules/@octopus/engine/dist/translator/emptyAction.js +1 -0
- package/node_modules/@octopus/engine/dist/translator/enterCapachaAction.d.ts +5 -0
- package/node_modules/@octopus/engine/dist/translator/enterCapachaAction.js +1 -0
- package/node_modules/@octopus/engine/dist/translator/enterTextAction.d.ts +5 -0
- package/node_modules/@octopus/engine/dist/translator/enterTextAction.js +1 -0
- package/node_modules/@octopus/engine/dist/translator/extractDataAction.d.ts +13 -0
- package/node_modules/@octopus/engine/dist/translator/extractDataAction.js +1 -0
- package/node_modules/@octopus/engine/dist/translator/loopAction.d.ts +5 -0
- package/node_modules/@octopus/engine/dist/translator/loopAction.js +1 -0
- package/node_modules/@octopus/engine/dist/translator/mouseOverAction.d.ts +5 -0
- package/node_modules/@octopus/engine/dist/translator/mouseOverAction.js +19 -0
- package/node_modules/@octopus/engine/dist/translator/navigateAction.d.ts +5 -0
- package/node_modules/@octopus/engine/dist/translator/navigateAction.js +117 -0
- package/node_modules/@octopus/engine/dist/translator/rootAction.d.ts +6 -0
- package/node_modules/@octopus/engine/dist/translator/rootAction.js +80 -0
- package/node_modules/@octopus/engine/dist/translator/switchCombo2Action.d.ts +5 -0
- package/node_modules/@octopus/engine/dist/translator/switchCombo2Action.js +19 -0
- package/node_modules/@octopus/engine/dist/translator/translator.d.ts +1 -0
- package/node_modules/@octopus/engine/dist/translator/translator.js +36 -0
- package/node_modules/@octopus/engine/dist/type.d.ts +25 -0
- package/node_modules/@octopus/engine/dist/type.js +2 -0
- package/node_modules/@octopus/engine/dist/types/browser.d.ts +191 -0
- package/node_modules/@octopus/engine/dist/types/browser.js +1 -0
- package/node_modules/@octopus/engine/dist/types/browserManager.d.ts +41 -0
- package/node_modules/@octopus/engine/dist/types/browserManager.js +1 -0
- package/node_modules/@octopus/engine/dist/types/index.d.ts +40 -0
- package/node_modules/@octopus/engine/dist/types/index.js +2 -0
- package/node_modules/@octopus/engine/dist/types/plugin.d.ts +29 -0
- package/node_modules/@octopus/engine/dist/types/plugin.js +2 -0
- package/node_modules/@octopus/engine/dist/utils/AsyncEmitter.d.ts +15 -0
- package/node_modules/@octopus/engine/dist/utils/AsyncEmitter.js +1 -0
- package/node_modules/@octopus/engine/dist/utils/DataStore.d.ts +58 -0
- package/node_modules/@octopus/engine/dist/utils/DataStore.js +1 -0
- package/node_modules/@octopus/engine/dist/utils/DateTimeFormatHelper.d.ts +22 -0
- package/node_modules/@octopus/engine/dist/utils/DateTimeFormatHelper.js +173 -0
- package/node_modules/@octopus/engine/dist/utils/FileDownloader.d.ts +108 -0
- package/node_modules/@octopus/engine/dist/utils/FileDownloader.js +1 -0
- package/node_modules/@octopus/engine/dist/utils/HttpRequester.d.ts +43 -0
- package/node_modules/@octopus/engine/dist/utils/HttpRequester.js +174 -0
- package/node_modules/@octopus/engine/dist/utils/JsonParser.d.ts +95 -0
- package/node_modules/@octopus/engine/dist/utils/JsonParser.js +439 -0
- package/node_modules/@octopus/engine/dist/utils/Operations.d.ts +27 -0
- package/node_modules/@octopus/engine/dist/utils/Operations.js +115 -0
- package/node_modules/@octopus/engine/dist/utils/index.d.ts +28 -0
- package/node_modules/@octopus/engine/dist/utils/index.js +356 -0
- package/node_modules/@octopus/engine/package.json +58 -0
- package/package.json +79 -0
- package/schemas/capabilities-v1.schema.json +234 -0
- package/schemas/detached-bootstrap-v1.schema.json +42 -0
- package/schemas/json-envelope-v1.schema.json +39 -0
- package/schemas/run-event-v1.schema.json +47 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import IBrowser from './browser';
|
|
2
|
+
export default interface IBrowserManager extends IBrowser {
|
|
3
|
+
/**
|
|
4
|
+
* 切换页面
|
|
5
|
+
* @param index 页面索引
|
|
6
|
+
*/
|
|
7
|
+
switchPage: (index: number) => void;
|
|
8
|
+
/**
|
|
9
|
+
* 新增页面
|
|
10
|
+
* @param url 页面地址
|
|
11
|
+
* @param loadOptions 页面加载参数
|
|
12
|
+
*/
|
|
13
|
+
addPage: (url: string, loadOptions?: any) => void;
|
|
14
|
+
/** 获取当前页面的索引 */
|
|
15
|
+
getCurrentPageIndex: () => number;
|
|
16
|
+
/** 获取总页面数 */
|
|
17
|
+
getPageCount: () => number;
|
|
18
|
+
/**
|
|
19
|
+
* 设置浏览器屏蔽广告
|
|
20
|
+
* @param disable 是否禁用
|
|
21
|
+
*/
|
|
22
|
+
setDisableAD: (disable: boolean) => void;
|
|
23
|
+
/**
|
|
24
|
+
* 设置浏览器禁止加载图片
|
|
25
|
+
* @param disable 是否禁用
|
|
26
|
+
*/
|
|
27
|
+
setDisableImage: (disable: boolean) => void;
|
|
28
|
+
/**
|
|
29
|
+
* 设置浏览器禁止加载样式
|
|
30
|
+
* @param disable 是否禁用
|
|
31
|
+
*/
|
|
32
|
+
setDisableStylesheet: (disable: boolean) => void;
|
|
33
|
+
/** 注册页面加载中状态回调 */
|
|
34
|
+
onPageLoading: (func: (...args: any[]) => void) => void;
|
|
35
|
+
/** 注册页面加载失败状态回调 */
|
|
36
|
+
onPageFailLoad: (func: (...args: any[]) => void) => void;
|
|
37
|
+
/** 注册页面加载完成状态回调 */
|
|
38
|
+
onPageLoaded: (func: (...args: any[]) => void) => void;
|
|
39
|
+
/** 注册页面标题发生更新回调 */
|
|
40
|
+
onPageTitleUpdated: (func: (...args: any[]) => void) => void;
|
|
41
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';Object['defineProperty'](exports,'__esModule',{'value':!![]});
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type BaseAction from '../actions/BaseAction';
|
|
2
|
+
export interface Variables {
|
|
3
|
+
/** 全局变量 */
|
|
4
|
+
globalContext: any;
|
|
5
|
+
/** 所有步骤实例 */
|
|
6
|
+
actions: Map<string, BaseAction>;
|
|
7
|
+
index?: number;
|
|
8
|
+
}
|
|
9
|
+
export interface ProxyMessage {
|
|
10
|
+
ip: string;
|
|
11
|
+
port?: number;
|
|
12
|
+
account?: string;
|
|
13
|
+
password?: string;
|
|
14
|
+
user?: string;
|
|
15
|
+
host?: string;
|
|
16
|
+
}
|
|
17
|
+
export interface TurnstileParams {
|
|
18
|
+
websiteKey: string;
|
|
19
|
+
websiteUrl: string;
|
|
20
|
+
taskId: string;
|
|
21
|
+
captchaType: number;
|
|
22
|
+
pageAction: string;
|
|
23
|
+
pageData: string;
|
|
24
|
+
userAgent: string;
|
|
25
|
+
data: string;
|
|
26
|
+
cloudflareTaskType: string;
|
|
27
|
+
lotno: string;
|
|
28
|
+
}
|
|
29
|
+
declare global {
|
|
30
|
+
interface Window {
|
|
31
|
+
turnstileFreezeParams?: any;
|
|
32
|
+
turnstileCallback?: (token: string) => void;
|
|
33
|
+
_turnstileInternal?: any;
|
|
34
|
+
turnstileErrorCallback?: (error: any) => void;
|
|
35
|
+
turnstile?: {
|
|
36
|
+
render: (a: string, b: any) => string;
|
|
37
|
+
[key: string]: any;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import EnterCaptchaAction from '../actions/EnterCaptchaAction';
|
|
2
|
+
import { CaptchaAvailableStatus, LocalCaptchaType } from '../enums';
|
|
3
|
+
import IBrowserManager from './browserManager';
|
|
4
|
+
export interface ExtraPlugin {
|
|
5
|
+
getImageCaptcha(image: string, url: string): Promise<string>;
|
|
6
|
+
getReCaptcha(key: string, url: string): Promise<string>;
|
|
7
|
+
getHCaptcha(key: string, url: string): Promise<string>;
|
|
8
|
+
getReCaptchaV3(key: string, action: string, url: string): Promise<string>;
|
|
9
|
+
getTurnstileToken(params: any): Promise<string>;
|
|
10
|
+
getOpenCloudflareStatus(): Promise<boolean>;
|
|
11
|
+
switchUA(browser: IBrowserManager, userAgents: Array<string>): void;
|
|
12
|
+
switchIP(proxyType: number, browser: IBrowserManager): Promise<string>;
|
|
13
|
+
/** 滑块点选专用 */
|
|
14
|
+
checkIsAvailable?(imageBase64: string): Promise<boolean>;
|
|
15
|
+
/** 获取滑块距离 */
|
|
16
|
+
getSlideCaptcha(image: string): Promise<{
|
|
17
|
+
id: string;
|
|
18
|
+
status: CaptchaAvailableStatus;
|
|
19
|
+
distance: number;
|
|
20
|
+
}>;
|
|
21
|
+
/** 获取点选坐标 */
|
|
22
|
+
getClickCaptcha(image: string, subImage: string): Promise<{
|
|
23
|
+
id: string;
|
|
24
|
+
status: CaptchaAvailableStatus;
|
|
25
|
+
clickArea: string[];
|
|
26
|
+
}>;
|
|
27
|
+
/** 开始滑块,点选打码 */
|
|
28
|
+
startCaptcha(type: LocalCaptchaType, action: EnterCaptchaAction): Promise<void>;
|
|
29
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import EventEmitter from 'node:events';
|
|
2
|
+
type AsyncEventMap = Record<string | symbol, any[]>;
|
|
3
|
+
type AsyncEventKey<Events extends AsyncEventMap> = Extract<keyof Events, string | symbol>;
|
|
4
|
+
/**
|
|
5
|
+
* 扩展 EventEmitter 支持异步事件发射
|
|
6
|
+
*/
|
|
7
|
+
export declare class AsyncEmitter<Events extends AsyncEventMap = AsyncEventMap> extends EventEmitter {
|
|
8
|
+
on<E extends AsyncEventKey<Events>>(eventName: E, listener: (...args: Events[E]) => void): this;
|
|
9
|
+
emit<E extends AsyncEventKey<Events>>(eventName: E, ...args: Events[E]): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* 异步发射事件,执行所有监听器并等待异步监听器完成
|
|
12
|
+
*/
|
|
13
|
+
emitAsync<E extends AsyncEventKey<Events>>(eventName: E, ...args: Events[E]): Promise<boolean>;
|
|
14
|
+
}
|
|
15
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var __importDefault=this&&this['__importDefault']||function(_0x4523a8){return _0x4523a8&&_0x4523a8['__esModule']?_0x4523a8:{'default':_0x4523a8};};Object['defineProperty'](exports,'__esModule',{'value':!![]}),exports['AsyncEmitter']=void 0x0;const node_events_1=__importDefault(require('node:events'));class AsyncEmitter extends node_events_1['default']{['on'](_0x13760e,_0x4a4ea1){return super['on'](_0x13760e,_0x4a4ea1);}['emit'](_0xe64b17,..._0x2c169a){return super['emit'](_0xe64b17,..._0x2c169a);}async['emitAsync'](_0xf8e38c,..._0x2b8580){const _0x16557a=super['listeners'](_0xf8e38c);if(_0x16557a['length']===0x0)return![];const _0x156d98=[];for(const _0x324f55 of _0x16557a){try{const _0x2dc48e=_0x324f55,_0x46d1b4=_0x2dc48e(..._0x2b8580);_0x46d1b4 instanceof Promise&&_0x156d98['push'](_0x46d1b4);}catch(_0x39dc33){console['error']('Error\x20in\x20listener\x20for\x20event\x20'+String(_0xf8e38c)+':',_0x39dc33);}}return _0x156d98['length']>0x0&&await Promise['allSettled'](_0x156d98),!![];}}exports['AsyncEmitter']=AsyncEmitter;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
interface RowData {
|
|
2
|
+
/** 行号 */
|
|
3
|
+
'#': number;
|
|
4
|
+
/** 行数据的唯一标识 */
|
|
5
|
+
$id: string;
|
|
6
|
+
/** 标记是否已执行保存数据库 */
|
|
7
|
+
$isSaved: boolean;
|
|
8
|
+
/** 字段 */
|
|
9
|
+
[index: string]: string | number | boolean;
|
|
10
|
+
}
|
|
11
|
+
export default class DataStore {
|
|
12
|
+
/** 数据表头 */
|
|
13
|
+
columns: any[];
|
|
14
|
+
/** 数据内容 */
|
|
15
|
+
dataSource: Array<RowData>;
|
|
16
|
+
/** 当前页码 */
|
|
17
|
+
page: number;
|
|
18
|
+
/** 数据总数 */
|
|
19
|
+
total: number;
|
|
20
|
+
/** 重复数据数量 */
|
|
21
|
+
repeatCount: number;
|
|
22
|
+
/** 加速模式下此时运行的子任务编号 */
|
|
23
|
+
subTaskID: number;
|
|
24
|
+
/** 固定的表格每页行数 */
|
|
25
|
+
readonly pageSize: number;
|
|
26
|
+
/** 采集暂停时临时存储当前数据 */
|
|
27
|
+
private tempDataSource;
|
|
28
|
+
/** 所有行数据 MD5 值,用来判断是否有重复数据 */
|
|
29
|
+
rowMD5s: Set<string>;
|
|
30
|
+
/** 最后一个提取步骤的序号 */
|
|
31
|
+
lastExtractIndex: number;
|
|
32
|
+
/** 上一次循环列表的执行次数 */
|
|
33
|
+
lastLoopTimes: number;
|
|
34
|
+
constructor();
|
|
35
|
+
/** 更新表头字段数据 */
|
|
36
|
+
updateColumns(fieldNames: Array<string>): void;
|
|
37
|
+
/** 生成一条空行数据,包含序号和全部字段 */
|
|
38
|
+
createEmptyRowData(): RowData;
|
|
39
|
+
/** 提取字段数据更新行数据 */
|
|
40
|
+
extractRowData(data: object, extractIndex: number, loopTimes: number, isRowAppend: boolean): RowData;
|
|
41
|
+
/** 增加一条子任务的行数据 */
|
|
42
|
+
addSubRowData(subRowData: RowData, subMD5: string): void;
|
|
43
|
+
/**
|
|
44
|
+
* 持久化当前最后一行数据,转换 XML、计算 MD5、压缩内容、写入数据库
|
|
45
|
+
* 为什么是最后一行?因为当前行在后面的提取步骤可能还会继续写入,所以需要在出现新行时落地上一行的数据,并且在采集完成时落地最后一条数据
|
|
46
|
+
* @todo 存储为 XML 格式是老版本的做法,后面可以改为 JSON 格式,更加方便读写
|
|
47
|
+
* PS: 改不了 XML 格式,因为本地数据需要云备份到服务端,那边的数据格式时固定的,改了格式就解析不了,改不动
|
|
48
|
+
*/
|
|
49
|
+
persistentRowData(): void;
|
|
50
|
+
/**
|
|
51
|
+
* 计算重复数据量,通过计算行数据的 MD5 存储起来来判断是否重复
|
|
52
|
+
* PS: 这里如果采 100 万条数据,就会存 100w 的 MD5,内存会不会占用太多?
|
|
53
|
+
*/
|
|
54
|
+
calcRepeatCount(md5: string): void;
|
|
55
|
+
/** 更新数据源,当数量超过预设的页面个数则截断,并增加页码 */
|
|
56
|
+
updateDataSource(): void;
|
|
57
|
+
}
|
|
58
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';Object['defineProperty'](exports,'__esModule',{'value':!![]});const lodash_1=require('lodash'),uuid_1=require('uuid'),defaultColumns=[{'dataIndex':'#'}];class DataStore{constructor(){this['columns']=[],this['dataSource']=[],this['page']=0x1,this['total']=0x0,this['repeatCount']=0x0,this['subTaskID']=0x0,this['pageSize']=0x14,this['tempDataSource']=[],this['rowMD5s']=new Set(),this['lastExtractIndex']=-0x1,this['lastLoopTimes']=0x0;}['updateColumns'](_0x38174e){const _0x1a4d38=_0x38174e['map'](_0x14275f=>({'title':_0x14275f,'dataIndex':_0x14275f}));this['columns']=defaultColumns['concat'](_0x1a4d38);}['createEmptyRowData'](){const _0x725d94={'#':this['dataSource']['length']+0x1,'$id':(0x0,uuid_1['v4'])(),'$isSaved':![]};for(const _0x98b5ad of this['columns']){const _0x1aba58=_0x98b5ad['dataIndex'];_0x1aba58!=='#'&&(_0x725d94[_0x1aba58]='');}return this['total']++,_0x725d94;}['extractRowData'](_0x3eaf17,_0x33eaa7,_0x4ca133,_0x3d9b55){let _0x3dbe2b;if(this['lastExtractIndex']===-0x1)_0x3dbe2b=this['createEmptyRowData']();else{if(_0x33eaa7>this['lastExtractIndex']||_0x3d9b55)_0x3dbe2b=this['dataSource']['pop']();else{if(_0x33eaa7<=this['lastExtractIndex']){_0x3dbe2b=this['createEmptyRowData']();const _0x13081b=(0x0,lodash_1['findIndex'])(this['columns'],{'dataIndex':Object['keys'](_0x3eaf17)[0x0]});for(let _0x5c592d=0x1;_0x5c592d<_0x13081b;_0x5c592d++){const _0x29c3c3=this['columns'][_0x5c592d]['dataIndex'];_0x3dbe2b[_0x29c3c3]=this['dataSource'][this['dataSource']['length']-0x1][_0x29c3c3];}}}}for(const _0x47bbbf of Object['keys'](_0x3eaf17)){const {value:_0x38f363,isAppend:_0x1b6d18}=_0x3eaf17[_0x47bbbf];_0x4ca133===this['lastLoopTimes']&&_0x1b6d18?_0x3dbe2b[_0x47bbbf]+='\x0d\x0a'+_0x38f363:_0x3dbe2b[_0x47bbbf]=_0x38f363;}return this['dataSource']['push'](_0x3dbe2b),this['lastExtractIndex']=_0x33eaa7,this['lastLoopTimes']=_0x4ca133,this['updateDataSource'](),_0x3dbe2b;}['addSubRowData'](_0x1e46fe,_0x3d8904){const _0x55382c={..._0x1e46fe,'#':this['dataSource']['length']+0x1};this['dataSource']['push'](_0x55382c),this['calcRepeatCount'](_0x3d8904),this['updateDataSource'](),this['total']++;}['persistentRowData'](){const _0xbe99e6=this['dataSource'][this['dataSource']['length']-0x1];if(_0xbe99e6&&!_0xbe99e6['$isSaved']){_0xbe99e6['$isSaved']=!![];const _0xfda7d1=_0xbe99e6['$id'];}}['calcRepeatCount'](_0xae9b78){this['rowMD5s']['has'](_0xae9b78)?this['repeatCount']++:this['rowMD5s']['add'](_0xae9b78);}['updateDataSource'](){if(this['dataSource']['length']>this['pageSize']){const _0x3ac513=this['dataSource']['pop']();_0x3ac513['#']=0x1,this['dataSource']=[_0x3ac513],this['page']++;}}}exports['default']=DataStore;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export default class DateTimeFormatHelper {
|
|
2
|
+
private static weekDesMap;
|
|
3
|
+
private static monthDesMap;
|
|
4
|
+
private static weekPlaceholder;
|
|
5
|
+
private static monthPlaceholder;
|
|
6
|
+
static personality: string;
|
|
7
|
+
static formatChinese(str: string, fmt?: string): string | number;
|
|
8
|
+
static format(input: Date, fmt: string): string;
|
|
9
|
+
private static dateTimeFormat;
|
|
10
|
+
/**
|
|
11
|
+
* JS Date()对象, 传入的参数在不指定具体年份的时候会设为默认的2001年,
|
|
12
|
+
* 这个方法用于调整默认年份,并返回添加年份后的字符串
|
|
13
|
+
* @param {string}
|
|
14
|
+
*/
|
|
15
|
+
static adjustDefaultYear(str: string): string | number;
|
|
16
|
+
/**
|
|
17
|
+
* 时区转换
|
|
18
|
+
* @param utc 时区偏移量
|
|
19
|
+
* @param input 需要转换的时间
|
|
20
|
+
*/
|
|
21
|
+
static timeZone(input: string, utc: string | number): string;
|
|
22
|
+
}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const moment_1 = __importDefault(require("moment"));
|
|
7
|
+
class DateTimeFormatHelper {
|
|
8
|
+
//处理日期格式为2019年12月20日情况
|
|
9
|
+
static formatChinese(str, fmt = '-') {
|
|
10
|
+
if (str.includes('年')) {
|
|
11
|
+
const formatedStr = str.replace('年', fmt).replace('月', fmt).replace('日', '');
|
|
12
|
+
return this.adjustDefaultYear(formatedStr);
|
|
13
|
+
}
|
|
14
|
+
return this.adjustDefaultYear(str);
|
|
15
|
+
}
|
|
16
|
+
static format(input, fmt) {
|
|
17
|
+
let reFmt = fmt;
|
|
18
|
+
let weekDes = this.weekDesMap[input.getDay()];
|
|
19
|
+
let monthDes = this.monthDesMap[input.getMonth()];
|
|
20
|
+
const noon = input.getHours() > 12 ? 'PM' : 'AM';
|
|
21
|
+
switch (fmt) {
|
|
22
|
+
case 'yyyy-MM-dd':
|
|
23
|
+
case 'yyyy/MM/dd':
|
|
24
|
+
reFmt = fmt;
|
|
25
|
+
break;
|
|
26
|
+
case 'd':
|
|
27
|
+
reFmt = 'MM/dd/yyyy';
|
|
28
|
+
break;
|
|
29
|
+
case 'D':
|
|
30
|
+
reFmt = `${this.weekPlaceholder},dd ${this.monthPlaceholder} yyyy`;
|
|
31
|
+
break;
|
|
32
|
+
case 'e':
|
|
33
|
+
reFmt = `${this.personality} ${noon}`;
|
|
34
|
+
break;
|
|
35
|
+
case 'E':
|
|
36
|
+
reFmt = 'yyyy年MM月dd日 hh時mm分';
|
|
37
|
+
break;
|
|
38
|
+
case 'f':
|
|
39
|
+
reFmt = `${this.weekPlaceholder},dd ${this.monthPlaceholder} yyyy hh:mm`;
|
|
40
|
+
break;
|
|
41
|
+
case 'F':
|
|
42
|
+
reFmt = `${this.weekPlaceholder},dd ${this.monthPlaceholder} yyyy hh:mm:ss`;
|
|
43
|
+
break;
|
|
44
|
+
case 'g':
|
|
45
|
+
reFmt = 'MM/yyyy/dd hh:mm';
|
|
46
|
+
break;
|
|
47
|
+
case 'G':
|
|
48
|
+
reFmt = 'MM/yyyy/dd hh:mm:ss';
|
|
49
|
+
break;
|
|
50
|
+
case 'm':
|
|
51
|
+
reFmt = `${this.monthPlaceholder} dd`;
|
|
52
|
+
break;
|
|
53
|
+
case 'r':
|
|
54
|
+
return input.toString();
|
|
55
|
+
case 's':
|
|
56
|
+
reFmt = 'yyyy-MM-ddThh:mm:ss';
|
|
57
|
+
break;
|
|
58
|
+
case 't':
|
|
59
|
+
reFmt = 'hh:mm';
|
|
60
|
+
break;
|
|
61
|
+
case 'T':
|
|
62
|
+
reFmt = 'hh:mm:ss';
|
|
63
|
+
break;
|
|
64
|
+
case 'u':
|
|
65
|
+
reFmt = 'yyyy-MM-dd hh:mm:ssZ';
|
|
66
|
+
break;
|
|
67
|
+
case 'U':
|
|
68
|
+
reFmt = `${this.weekPlaceholder},dd ${this.monthPlaceholder} yyyy hh:mm:ss`;
|
|
69
|
+
break;
|
|
70
|
+
case 'y':
|
|
71
|
+
reFmt = `yyyy ${this.monthPlaceholder}`;
|
|
72
|
+
break;
|
|
73
|
+
case 'M':
|
|
74
|
+
reFmt = `${this.monthPlaceholder} dd`;
|
|
75
|
+
break;
|
|
76
|
+
case 'Y':
|
|
77
|
+
reFmt = `yyyy ${this.monthPlaceholder}`;
|
|
78
|
+
break;
|
|
79
|
+
default:
|
|
80
|
+
reFmt = fmt;
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
let formatOutput = this.dateTimeFormat(input, reFmt);
|
|
84
|
+
let output1Reg = new RegExp(this.weekPlaceholder, 'g');
|
|
85
|
+
let output2Reg = new RegExp(this.monthPlaceholder, 'g');
|
|
86
|
+
let output1 = formatOutput.replace(output1Reg, weekDes);
|
|
87
|
+
let output2 = output1.replace(output2Reg, monthDes);
|
|
88
|
+
return output2;
|
|
89
|
+
}
|
|
90
|
+
static dateTimeFormat(input, fmt) {
|
|
91
|
+
let o = {
|
|
92
|
+
'M+': input.getMonth() + 1, //月份
|
|
93
|
+
'd+': input.getDate(), //日
|
|
94
|
+
'H+': input.getHours(),
|
|
95
|
+
'h+': input.getHours() == 12 ? 12 : input.getHours() % 12, //小时
|
|
96
|
+
'm+': input.getMinutes(), //分
|
|
97
|
+
's+': input.getSeconds(), //秒
|
|
98
|
+
'q+': Math.floor((input.getMonth() + 3) / 3), //季度
|
|
99
|
+
S: input.getMilliseconds(), //毫秒
|
|
100
|
+
};
|
|
101
|
+
if (/(y+)/.test(fmt))
|
|
102
|
+
fmt = fmt.replace(RegExp.$1, (input.getFullYear() + '').substr(4 - RegExp.$1.length));
|
|
103
|
+
for (var k in o)
|
|
104
|
+
if (new RegExp('(' + k + ')').test(fmt))
|
|
105
|
+
fmt = fmt.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ('00' + o[k]).substr(('' + o[k]).length));
|
|
106
|
+
return fmt;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* JS Date()对象, 传入的参数在不指定具体年份的时候会设为默认的2001年,
|
|
110
|
+
* 这个方法用于调整默认年份,并返回添加年份后的字符串
|
|
111
|
+
* @param {string}
|
|
112
|
+
*/
|
|
113
|
+
static adjustDefaultYear(str) {
|
|
114
|
+
// 判断2001年是参数自带的还是new Date()默认提供的
|
|
115
|
+
if (new Date(str) && new Date(str).getFullYear() === 2001) {
|
|
116
|
+
if (str.indexOf('2001') > 0) {
|
|
117
|
+
return str;
|
|
118
|
+
}
|
|
119
|
+
// 2001是new Date()自动设置的默认值,需要替换为当前时间
|
|
120
|
+
let year = new Date().getFullYear();
|
|
121
|
+
// 如果加上今年的年份大于现在的时间,需要变成去年的年份
|
|
122
|
+
if ((0, moment_1.default)(new Date(str).setFullYear(year)).isAfter((0, moment_1.default)())) {
|
|
123
|
+
year = year - 1;
|
|
124
|
+
}
|
|
125
|
+
// 把年份设置成当前年,并返回日期字符串
|
|
126
|
+
return new Date(str).setFullYear(year);
|
|
127
|
+
// 补充一句:new Date()里面传入的参数为时间戳时必须为number类型,否则会输出invalid Date,所以这个函数的返回值类型保持string和number
|
|
128
|
+
}
|
|
129
|
+
return str;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* 时区转换
|
|
133
|
+
* @param utc 时区偏移量
|
|
134
|
+
* @param input 需要转换的时间
|
|
135
|
+
*/
|
|
136
|
+
static timeZone(input, utc) {
|
|
137
|
+
try {
|
|
138
|
+
// const date = new Date(input);
|
|
139
|
+
const utcDate = (0, moment_1.default)(input).add(Number(utc), 'hour').format('YYYY-MM-DD HH:mm:ss');
|
|
140
|
+
return moment_1.default.utc(new Date(utcDate)).format('YYYY-MM-DD HH:mm:ss');
|
|
141
|
+
}
|
|
142
|
+
catch (error) {
|
|
143
|
+
return 'Invalid date';
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
DateTimeFormatHelper.weekDesMap = {
|
|
148
|
+
0: 'Sunday',
|
|
149
|
+
1: 'Monday',
|
|
150
|
+
2: 'Tuesday',
|
|
151
|
+
3: 'Wednesday',
|
|
152
|
+
4: 'Thursday',
|
|
153
|
+
5: 'Friday',
|
|
154
|
+
6: 'Saturday',
|
|
155
|
+
};
|
|
156
|
+
DateTimeFormatHelper.monthDesMap = {
|
|
157
|
+
0: 'January',
|
|
158
|
+
1: 'February',
|
|
159
|
+
2: 'March',
|
|
160
|
+
3: 'April',
|
|
161
|
+
4: 'May',
|
|
162
|
+
5: 'June',
|
|
163
|
+
6: 'July',
|
|
164
|
+
7: 'August',
|
|
165
|
+
8: 'September',
|
|
166
|
+
9: 'October',
|
|
167
|
+
10: 'November',
|
|
168
|
+
11: 'December',
|
|
169
|
+
};
|
|
170
|
+
DateTimeFormatHelper.weekPlaceholder = '@###@';
|
|
171
|
+
DateTimeFormatHelper.monthPlaceholder = '@#@';
|
|
172
|
+
DateTimeFormatHelper.personality = 'yyyy/MM/dd hh:mm:ss';
|
|
173
|
+
exports.default = DateTimeFormatHelper;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { Page } from 'puppeteer-core';
|
|
2
|
+
import { ExtractItem } from '../models/extractItem';
|
|
3
|
+
export interface DownloadOptions {
|
|
4
|
+
/** 下载目录路径 (对应旧版 threeFolderPath: 根目录/任务名/时间/) */
|
|
5
|
+
downloadPath: string;
|
|
6
|
+
/** 字段名 */
|
|
7
|
+
fieldName?: string;
|
|
8
|
+
/** 日志回调函数 */
|
|
9
|
+
logCallback?: (message: string) => void;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* 文件下载工具类
|
|
13
|
+
* 通过 Puppeteer Response 拦截实现文件下载
|
|
14
|
+
*/
|
|
15
|
+
export declare class FileDownloader {
|
|
16
|
+
private page;
|
|
17
|
+
private options;
|
|
18
|
+
/** MIME 类型到文件扩展名的映射表 */
|
|
19
|
+
private static readonly MIME_TO_EXTENSION;
|
|
20
|
+
constructor(page: Page, options: DownloadOptions);
|
|
21
|
+
/**
|
|
22
|
+
* 下载文件
|
|
23
|
+
* @param url 下载链接
|
|
24
|
+
* @param extractItem 提取项配置
|
|
25
|
+
* @returns 下载后的文件路径和文件大小
|
|
26
|
+
*/
|
|
27
|
+
downloadFile(url: string, extractItem: ExtractItem): Promise<{
|
|
28
|
+
filePath: string;
|
|
29
|
+
fileSize: number;
|
|
30
|
+
}>;
|
|
31
|
+
/**
|
|
32
|
+
* 使用 Response 拦截下载单个文件
|
|
33
|
+
* @param url 下载链接
|
|
34
|
+
* @param extractItem 提取项配置
|
|
35
|
+
* @returns 下载后的文件路径和文件大小
|
|
36
|
+
*/
|
|
37
|
+
private downloadSingleFile;
|
|
38
|
+
/**
|
|
39
|
+
* 触发下载请求
|
|
40
|
+
* @param url 下载链接
|
|
41
|
+
*/
|
|
42
|
+
private triggerDownloadRequest;
|
|
43
|
+
/**
|
|
44
|
+
* 判断两个 URL 是否指向同一资源
|
|
45
|
+
* @param url1 URL 1
|
|
46
|
+
* @param url2 URL 2
|
|
47
|
+
* @returns 是否相同
|
|
48
|
+
*/
|
|
49
|
+
private isSameResource;
|
|
50
|
+
/**
|
|
51
|
+
* 从响应中提取文件名和扩展名
|
|
52
|
+
* @param response Puppeteer Response 对象
|
|
53
|
+
* @param url 原始 URL
|
|
54
|
+
* @returns { name: 文件名, ext: 扩展名 }
|
|
55
|
+
*/
|
|
56
|
+
private extractFileNameParts;
|
|
57
|
+
/**
|
|
58
|
+
* 根据 Content-Type 获取文件扩展名
|
|
59
|
+
* @param contentType MIME 类型
|
|
60
|
+
* @returns 文件扩展名
|
|
61
|
+
*/
|
|
62
|
+
private getExtensionByContentType;
|
|
63
|
+
/**
|
|
64
|
+
* 日志输出
|
|
65
|
+
*/
|
|
66
|
+
private log;
|
|
67
|
+
/**
|
|
68
|
+
* 格式化文件名,去除非法字符
|
|
69
|
+
* @param name 原始名称
|
|
70
|
+
* @returns 格式化后的名称
|
|
71
|
+
*/
|
|
72
|
+
private formatName;
|
|
73
|
+
/**
|
|
74
|
+
* 格式化扩展名,确保以点开头
|
|
75
|
+
* @param ext 扩展名
|
|
76
|
+
* @returns 格式化后的扩展名
|
|
77
|
+
*/
|
|
78
|
+
private formatExtension;
|
|
79
|
+
/**
|
|
80
|
+
* 构建下载目录路径
|
|
81
|
+
* 对应旧版逻辑: threeFolderPath/fieldName
|
|
82
|
+
* @returns 下载目录路径
|
|
83
|
+
*/
|
|
84
|
+
private buildThreeFolderPath;
|
|
85
|
+
/**
|
|
86
|
+
* 计算 Buffer 的 MD5 值
|
|
87
|
+
* @param buffer 文件内容
|
|
88
|
+
* @returns MD5 哈希值
|
|
89
|
+
*/
|
|
90
|
+
private calculateMD5;
|
|
91
|
+
/**
|
|
92
|
+
* 根据配置生成文件名
|
|
93
|
+
* @param originalName 原始文件名
|
|
94
|
+
* @param extension 文件扩展名
|
|
95
|
+
* @param buffer 文件内容
|
|
96
|
+
* @param extractItem 提取项配置
|
|
97
|
+
* @returns 格式化后的文件名(含扩展名)
|
|
98
|
+
*/
|
|
99
|
+
private generateFileName;
|
|
100
|
+
/**
|
|
101
|
+
* 处理重名文件
|
|
102
|
+
* @param filePath 目标文件路径
|
|
103
|
+
* @param buffer 文件内容
|
|
104
|
+
* @param extractItem 提取项配置
|
|
105
|
+
* @returns 最终保存的文件路径
|
|
106
|
+
*/
|
|
107
|
+
private handleDuplicateFile;
|
|
108
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var __createBinding=this&&this['__createBinding']||(Object['create']?function(_0xdc1bc6,_0x50eeea,_0x44f73e,_0x35dbe6){if(_0x35dbe6===undefined)_0x35dbe6=_0x44f73e;var _0x5389b6=Object['getOwnPropertyDescriptor'](_0x50eeea,_0x44f73e);(!_0x5389b6||('get'in _0x5389b6?!_0x50eeea['__esModule']:_0x5389b6['writable']||_0x5389b6['configurable']))&&(_0x5389b6={'enumerable':!![],'get':function(){return _0x50eeea[_0x44f73e];}}),Object['defineProperty'](_0xdc1bc6,_0x35dbe6,_0x5389b6);}:function(_0x22e204,_0x1d627e,_0x2d0508,_0x38c8f5){if(_0x38c8f5===undefined)_0x38c8f5=_0x2d0508;_0x22e204[_0x38c8f5]=_0x1d627e[_0x2d0508];}),__setModuleDefault=this&&this['__setModuleDefault']||(Object['create']?function(_0x7c1f4f,_0xc7b1a3){Object['defineProperty'](_0x7c1f4f,'default',{'enumerable':!![],'value':_0xc7b1a3});}:function(_0x512225,_0x59697f){_0x512225['default']=_0x59697f;}),__importStar=this&&this['__importStar']||(function(){var _0x24e10f=function(_0x59a622){return _0x24e10f=Object['getOwnPropertyNames']||function(_0x346869){var _0x16bb7f=[];for(var _0x2e8d94 in _0x346869)if(Object['prototype']['hasOwnProperty']['call'](_0x346869,_0x2e8d94))_0x16bb7f[_0x16bb7f['length']]=_0x2e8d94;return _0x16bb7f;},_0x24e10f(_0x59a622);};return function(_0x1a39cf){if(_0x1a39cf&&_0x1a39cf['__esModule'])return _0x1a39cf;var _0x51b6a3={};if(_0x1a39cf!=null){for(var _0x2ff7d4=_0x24e10f(_0x1a39cf),_0x50794e=0x0;_0x50794e<_0x2ff7d4['length'];_0x50794e++)if(_0x2ff7d4[_0x50794e]!=='default')__createBinding(_0x51b6a3,_0x1a39cf,_0x2ff7d4[_0x50794e]);}return __setModuleDefault(_0x51b6a3,_0x1a39cf),_0x51b6a3;};}()),__importDefault=this&&this['__importDefault']||function(_0xfabaa8){return _0xfabaa8&&_0xfabaa8['__esModule']?_0xfabaa8:{'default':_0xfabaa8};};Object['defineProperty'](exports,'__esModule',{'value':!![]}),exports['FileDownloader']=void 0x0;const path=__importStar(require('path')),fs=__importStar(require('fs')),crypto=__importStar(require('crypto')),utils_1=require('../utils'),moment_1=__importDefault(require('moment')),enums_1=require('../enums');class FileDownloader{constructor(_0x3162b5,_0x2fdb6f){this['page']=_0x3162b5,this['options']=_0x2fdb6f;}async['downloadFile'](_0x1eac04,_0x8912ed){if((0x0,utils_1['isNullOrEmpty'])(_0x1eac04))throw new Error('下载链接为空');const _0x482afd=_0x8912ed['DownloadFileConfig'];console['log']('|config',_0x482afd);let _0x3235bd=[_0x1eac04];if(_0x482afd['mutipleUrlConfig']['isIncludeMutipleUrl']){const _0x413d0d=_0x482afd['mutipleUrlConfig']['urlSplitType'],_0x21a03f=['\x0a',',','\x20'],_0x38fb67=_0x21a03f[_0x413d0d]||'\x0a',_0x457064=_0x1eac04['includes'](_0x38fb67);if(_0x457064)_0x3235bd=_0x1eac04['split'](_0x38fb67)['map'](_0x6af2d6=>_0x6af2d6['trim']())['filter'](_0x2fe2b3=>!(0x0,utils_1['isNullOrEmpty'])(_0x2fe2b3));else throw new Error('URL拆分失败:未找到分隔符\x20\x22'+_0x38fb67+'\x22');}const _0x26908c=[];let _0x517fa3=0x0;for(const _0x979f69 of _0x3235bd){if(_0x482afd['excludeUrls']&&_0x482afd['excludeUrls']['includes'](_0x979f69)){this['log']('跳过下载排除的链接:\x20'+_0x979f69);continue;}const _0x5318be=await this['downloadSingleFile'](_0x979f69,_0x8912ed);_0x26908c['push'](_0x5318be['filePath']),_0x517fa3+=_0x5318be['fileSize'];}return{'filePath':_0x26908c['join'](';\x20'),'fileSize':_0x517fa3};}async['downloadSingleFile'](_0x4b44ff,_0x36157e){const _0x101441=_0x4b44ff['replace'](/&/g,'&')['replace'](/</g,'<')['replace'](/>/g,'>')['replace'](/"/g,'\x22');let _0x3a92e2='',_0x3374f4=0x0,_0x2798a9=![],_0x8b14af=null;const _0x1deb96=async _0x18aae3=>{try{const _0x4d3a67=_0x18aae3['url'](),_0x5df09e=_0x18aae3['status']();if(!this['isSameResource'](_0x4d3a67,_0x101441))return;if(_0x5df09e>=0x12c&&_0x5df09e<0x190)return;const _0x5eafc6=await _0x18aae3['buffer']();_0x3374f4=_0x5eafc6['length'];const {name:_0x452367,ext:_0x212323}=this['extractFileNameParts'](_0x18aae3,_0x101441),_0x284b31=this['buildThreeFolderPath'](),_0x11c5e9=this['generateFileName'](_0x452367,_0x212323,_0x5eafc6,_0x36157e),_0x1f4ed6=path['join'](_0x284b31,_0x11c5e9);_0x3a92e2=await this['handleDuplicateFile'](_0x1f4ed6,_0x5eafc6,_0x36157e),_0x2798a9=!![];}catch(_0x350068){_0x8b14af=_0x350068 instanceof Error?_0x350068:new Error(String(_0x350068)),_0x2798a9=!![];}};this['page']['on']('response',_0x1deb96);try{await this['triggerDownloadRequest'](_0x101441);const _0x26497b=Date['now'](),_0x4d7996=0xea60;while(!_0x2798a9&&Date['now']()-_0x26497b<_0x4d7996){await new Promise(_0x4b4372=>setTimeout(_0x4b4372,0x64));}if(!_0x2798a9)throw new Error('下载超时:未收到响应');if(_0x8b14af)throw _0x8b14af;if(!_0x3a92e2)throw new Error('下载失败:未能保存文件');return{'filePath':_0x3a92e2,'fileSize':_0x3374f4};}finally{this['page']['off']('response',_0x1deb96);}}async['triggerDownloadRequest'](_0x2a08b0){try{await this['page']['evaluate'](_0x3a63ef=>{return fetch(_0x3a63ef,{'method':'GET','credentials':'include'});},_0x2a08b0);}catch(_0x28bf99){console['log']('error',_0x28bf99),await this['page']['evaluate'](_0x145f62=>{return new Promise(_0x262a0f=>{console['log']('使用图片元素触发下载请求');const _0x443824=document['createElement']('img');_0x443824['style']['display']='none',_0x443824['src']=_0x145f62,document['body']['appendChild'](_0x443824),setTimeout(()=>_0x262a0f(undefined),0x64);});},_0x2a08b0);}}['isSameResource'](_0x57a9cb,_0x4a20f8){try{const _0x1e7325=new URL(_0x57a9cb),_0x5725ce=new URL(_0x4a20f8);if(_0x1e7325['origin']!==_0x5725ce['origin']||_0x1e7325['pathname']!==_0x5725ce['pathname'])return![];return!![];}catch(_0x402017){return _0x57a9cb===_0x4a20f8;}}['extractFileNameParts'](_0x2755fe,_0x3f5305){var _0x37fb31;const _0xdfac5c=_0x2755fe['headers'](),_0x376ac0=_0xdfac5c['content-disposition'];if(_0x376ac0){const _0x1e2944=[_0x376ac0['match'](/filename\*=UTF-8''([^;]+)/i),_0x376ac0['match'](/filename="([^"]+)"/i),_0x376ac0['match'](/filename=([^;]+)/i)];for(const _0x165a20 of _0x1e2944){if(_0x165a20&&_0x165a20[0x1])try{const _0x2b8176=decodeURIComponent(_0x165a20[0x1]['trim']());if(_0x2b8176){const _0x5cd276=path['parse'](_0x2b8176);return{'name':_0x5cd276['name'],'ext':_0x5cd276['ext']};}}catch(_0x234b57){}}}try{const _0x3e6c25=new URL(_0x3f5305),_0x13e142=_0x3e6c25['pathname'],_0x3190dd=path['basename'](_0x13e142);if(_0x3190dd&&_0x3190dd['includes']('.')&&_0x3190dd['length']>0x1){const _0x568667=decodeURIComponent(_0x3190dd),_0xb1881=path['parse'](_0x568667);return{'name':_0xb1881['name'],'ext':_0xb1881['ext']};}}catch(_0x251440){}const _0x4c12ab=(_0x37fb31=_0xdfac5c['content-type'])===null||_0x37fb31===void 0x0?void 0x0:_0x37fb31['split'](';')[0x0]['trim'](),_0x4ae646=this['getExtensionByContentType'](_0x4c12ab);return{'name':'download_'+Date['now'](),'ext':'.'+_0x4ae646};}['getExtensionByContentType'](_0x31a22c){return FileDownloader['MIME_TO_EXTENSION'][_0x31a22c]||'bin';}['log'](_0x1572ab){this['options']['logCallback']&&this['options']['logCallback'](_0x1572ab);}['formatName'](_0x5aa5d3){return _0x5aa5d3['replace'](/[\\/:*?"<>|]/g,'_');}['formatExtension'](_0xd89576){return _0xd89576['startsWith']('.')?_0xd89576:'.'+_0xd89576;}['buildThreeFolderPath'](){const _0x3dca25=[this['options']['downloadPath']];this['options']['fieldName']&&_0x3dca25['push'](this['formatName'](this['options']['fieldName']));const _0x5ab516=path['join'](..._0x3dca25);return!fs['existsSync'](_0x5ab516)&&fs['mkdirSync'](_0x5ab516,{'recursive':!![]}),_0x5ab516;}['calculateMD5'](_0xc402af){return crypto['createHash']('md5')['update'](_0xc402af)['digest']('hex');}['generateFileName'](_0x83bd3,_0x557535,_0xa2e18e,_0x2c7299){const _0x297381=_0x2c7299['DownloadFileConfig'];let _0x276513=_0x83bd3;switch(_0x297381['downloadFileRenameType']){case enums_1['DownloadFileRenameType']['SourceFileMD5']:_0x276513=this['calculateMD5'](_0xa2e18e);break;case enums_1['DownloadFileRenameType']['AcquisitionTime']:_0x276513=(0x0,moment_1['default'])()['format']('HHmmssSSS');break;case enums_1['DownloadFileRenameType']['FieldValue']:_0x297381['field']&&(_0x276513=_0x297381['field']);break;case enums_1['DownloadFileRenameType']['SourceFileName']:default:_0x276513=_0x83bd3;break;}return this['formatName'](_0x276513)+this['formatExtension'](_0x557535);}async['handleDuplicateFile'](_0xe3c4fc,_0x122d46,_0xaeba0a){const _0x295556=_0xaeba0a['DownloadFileConfig'];if(!fs['existsSync'](_0xe3c4fc))return await fs['promises']['writeFile'](_0xe3c4fc,_0x122d46),_0xe3c4fc;switch(_0x295556['repeatValue']){case enums_1['DownloadFileNameRepeatType']['Cover']:await fs['promises']['writeFile'](_0xe3c4fc,_0x122d46),this['log']('文件已覆盖:\x20'+_0xe3c4fc);return _0xe3c4fc;case enums_1['DownloadFileNameRepeatType']['SkipNonDownload']:this['log']('文件已存在,跳过下载:\x20'+_0xe3c4fc);throw new Error('文件已存在,跳过下载:\x20'+_0xe3c4fc);case enums_1['DownloadFileNameRepeatType']['AutoRename']:default:const _0x3c9304=path['parse'](_0xe3c4fc);let _0x8fbb15=0x2,_0x307210=path['join'](_0x3c9304['dir'],_0x3c9304['name']+'\x20('+_0x8fbb15+')'+_0x3c9304['ext']);while(fs['existsSync'](_0x307210)){_0x8fbb15++,_0x307210=path['join'](_0x3c9304['dir'],_0x3c9304['name']+'\x20('+_0x8fbb15+')'+_0x3c9304['ext']);}await fs['promises']['writeFile'](_0x307210,_0x122d46),this['log']('文件自动重命名:\x20'+_0x307210);return _0x307210;}}}exports['FileDownloader']=FileDownloader,FileDownloader['MIME_TO_EXTENSION']={'image/jpeg':'jpg','image/png':'png','image/gif':'gif','image/webp':'webp','image/svg+xml':'svg','image/bmp':'bmp','image/tiff':'tiff','application/pdf':'pdf','application/msword':'doc','application/vnd.openxmlformats-officedocument.wordprocessingml.document':'docx','application/vnd.ms-excel':'xls','application/vnd.openxmlformats-officedocument.spreadsheetml.sheet':'xlsx','application/vnd.ms-powerpoint':'ppt','application/vnd.openxmlformats-officedocument.presentationml.presentation':'pptx','text/plain':'txt','text/csv':'csv','application/zip':'zip','application/x-rar-compressed':'rar','application/x-7z-compressed':'7z','application/x-tar':'tar','application/gzip':'gz','video/mp4':'mp4','video/mpeg':'mpeg','video/webm':'webm','video/quicktime':'mov','video/x-msvideo':'avi','audio/mpeg':'mp3','audio/wav':'wav','audio/ogg':'ogg','audio/webm':'weba','application/json':'json','application/xml':'xml','text/html':'html'};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { EventEmitter } from 'events';
|
|
2
|
+
import { CustomizeCookie } from '../models/customizeCookie';
|
|
3
|
+
export declare class HttpRequester extends EventEmitter {
|
|
4
|
+
static xForwardFor: string;
|
|
5
|
+
static userAgent: string;
|
|
6
|
+
static cookies?: CustomizeCookie[];
|
|
7
|
+
isRequesting: boolean;
|
|
8
|
+
onRequested?: (response: any) => void;
|
|
9
|
+
onRequesting?: (args: any) => void;
|
|
10
|
+
onRequestError?: (error: any) => void;
|
|
11
|
+
onRequestStopped?: () => void;
|
|
12
|
+
constructor();
|
|
13
|
+
startRequest(url: string, method: string, headers: Map<string, string>, bodyContent: string, timeout: number, requestCallback?: (response?: unknown) => void): Promise<void>;
|
|
14
|
+
/**
|
|
15
|
+
* 判断网页地址是否包含中文字符
|
|
16
|
+
* @param str
|
|
17
|
+
*/
|
|
18
|
+
static checkChinese(str: string): boolean;
|
|
19
|
+
}
|
|
20
|
+
export declare class RequestingArgs {
|
|
21
|
+
url: string;
|
|
22
|
+
method: string;
|
|
23
|
+
requestHeaders: Map<string, string>;
|
|
24
|
+
bodyContent: string;
|
|
25
|
+
cancel: boolean;
|
|
26
|
+
constructor(url: string, method: string, requestHeaders: Map<string, string>, bodyContent: string);
|
|
27
|
+
}
|
|
28
|
+
export declare class RequestedArgs {
|
|
29
|
+
url: string;
|
|
30
|
+
statusCode: number;
|
|
31
|
+
encoding: string;
|
|
32
|
+
responseString: string;
|
|
33
|
+
response: any;
|
|
34
|
+
constructor(url: string, statusCode: number, responseString: string, encoding: string, response: any);
|
|
35
|
+
}
|
|
36
|
+
export declare class RequestErrorArgs {
|
|
37
|
+
url: string;
|
|
38
|
+
error: any;
|
|
39
|
+
constructor(url: string, error: any);
|
|
40
|
+
statusCode: number;
|
|
41
|
+
responseString: string;
|
|
42
|
+
get ErrorSummary(): string;
|
|
43
|
+
}
|