Quellcode durchsuchen

Can Resize toolbox

naibo vor 2 Jahren
Ursprung
Commit
feb3a037b2

+ 27 - 6
.temp_to_pub/EasySpider_windows_x64/Code/easyspider_executestage.py

@@ -42,7 +42,7 @@ from PIL import Image
 # import uuid
 from threading import Thread, Event
 from myChrome import MyChrome, MyUCChrome
-from utils import check_pause, download_image, get_output_code, isnull, myMySQL, new_line, write_to_csv, write_to_excel
+from utils import check_pause, download_image, get_output_code, isnull, lowercase_tags_in_xpath, myMySQL, new_line, write_to_csv, write_to_excel
 desired_capabilities = DesiredCapabilities.CHROME
 desired_capabilities["pageLoadStrategy"] = "none"
 
@@ -174,6 +174,11 @@ class BrowserThread(Thread):
                 iframe = node["parameters"]["iframe"]
             except:
                 node["parameters"]["iframe"] = False
+            try:
+                node["parameters"]["xpath"] = lowercase_tags_in_xpath(
+                    node["parameters"]["xpath"])
+            except:
+                pass
             if node["option"] == 1:  # 打开网页操作
                 try:
                     cookies = node["parameters"]["cookies"]
@@ -186,6 +191,10 @@ class BrowserThread(Thread):
                         iframe = para["iframe"]
                     except:
                         para["iframe"] = False
+                    try:
+                        para["relativeXPath"] = lowercase_tags_in_xpath(para["relativeXPath"])
+                    except:
+                        pass
                     if para["beforeJS"] == "" and para["afterJS"] == "" and para["contentType"] <= 1 and para["nodeType"] <= 2:
                         para["optimizable"] = True
                     else:
@@ -1158,13 +1167,24 @@ class BrowserThread(Thread):
                     if self.browser.iframe_env != p["iframe"]:
                         p["optimizable"] = False
                         continue
-                    p["relativeXPath"] = p["relativeXPath"].lower()
+                    # p["relativeXPath"] = p["relativeXPath"].lower()
+                    # p["relativeXPath"] = lowercase_tags_in_xpath(p["relativeXPath"])
                     if p["nodeType"] == 2:
-                        xpath = p["relativeXPath"] + "/@href"
+                        if p["relativeXPath"].find("/@href") >= 0:
+                            xpath = p["relativeXPath"]
+                        else:
+                            xpath = p["relativeXPath"] + "/@href"
                     elif p["contentType"] == 1:
-                        xpath = p["relativeXPath"] + "/text()"
+                        # 已经有text()了,不需要再加
+                        if p["relativeXPath"].find("/text()") >= 0 or p["relativeXPath"].find("::text()") >= 0:
+                            xpath = p["relativeXPath"]
+                        else:
+                            xpath = p["relativeXPath"] + "/text()"
                     elif p["contentType"] == 0:
-                        xpath = p["relativeXPath"] + "//text()"
+                        if p["relativeXPath"].find("/text()") >= 0 or p["relativeXPath"].find("::text()") >= 0:
+                            xpath = p["relativeXPath"]
+                        else:
+                            xpath = p["relativeXPath"] + "//text()"
                     if p["relative"]:
                         # if p["relativeXPath"] == "":
                         #     content = [loopElementHTML]
@@ -1214,7 +1234,8 @@ class BrowserThread(Thread):
                 content = ""
                 if not (p["contentType"] == 5 or p["contentType"] == 6):  # 如果不是页面标题或URL,去找元素
                     try:
-                        p["relativeXPath"] = p["relativeXPath"].lower()
+                        # p["relativeXPath"] = p["relativeXPath"].lower()
+                        # p["relativeXPath"] = lowercase_tags_in_xpath(p["relativeXPath"])
                         if p["relative"]:  # 是否相对xpath
                             if p["relativeXPath"] == "":  # 相对xpath有时候就是元素本身,不需要二次查找
                                 element = loopElement

+ 4 - 0
.temp_to_pub/EasySpider_windows_x64/Code/utils.py

@@ -4,6 +4,7 @@ import csv
 import datetime
 import json
 import os
+import re
 import time
 import uuid
 import keyboard
@@ -11,6 +12,7 @@ from openpyxl import Workbook, load_workbook
 import requests
 from urllib.parse import urlparse
 import pymysql
+from lxml import etree
 
 def is_valid_url(url):
     try:
@@ -19,6 +21,8 @@ def is_valid_url(url):
     except ValueError:
         return False
 
+def lowercase_tags_in_xpath(xpath):
+    return re.sub(r"([A-Z]+)(?=[\[\]//]|$)", lambda x: x.group(0).lower(), xpath)
 
 def check_pause(key, event):
     while True:

Datei-Diff unterdrückt, da er zu groß ist
+ 0 - 0
.temp_to_pub/EasySpider_windows_x64/execution_instances/0.json


Datei-Diff unterdrückt, da er zu groß ist
+ 0 - 0
.temp_to_pub/EasySpider_windows_x64/execution_instances/1.json


Datei-Diff unterdrückt, da er zu groß ist
+ 0 - 0
.temp_to_pub/EasySpider_windows_x64/execution_instances/10.json


Datei-Diff unterdrückt, da er zu groß ist
+ 0 - 0
.temp_to_pub/EasySpider_windows_x64/execution_instances/11.json


Datei-Diff unterdrückt, da er zu groß ist
+ 0 - 0
.temp_to_pub/EasySpider_windows_x64/execution_instances/2.json


Datei-Diff unterdrückt, da er zu groß ist
+ 0 - 0
.temp_to_pub/EasySpider_windows_x64/execution_instances/3.json


Datei-Diff unterdrückt, da er zu groß ist
+ 0 - 0
.temp_to_pub/EasySpider_windows_x64/execution_instances/4.json


Datei-Diff unterdrückt, da er zu groß ist
+ 0 - 0
.temp_to_pub/EasySpider_windows_x64/execution_instances/5.json


Datei-Diff unterdrückt, da er zu groß ist
+ 0 - 0
.temp_to_pub/EasySpider_windows_x64/execution_instances/6.json


Datei-Diff unterdrückt, da er zu groß ist
+ 0 - 0
.temp_to_pub/EasySpider_windows_x64/execution_instances/7.json


Datei-Diff unterdrückt, da er zu groß ist
+ 0 - 0
.temp_to_pub/EasySpider_windows_x64/execution_instances/8.json


Datei-Diff unterdrückt, da er zu groß ist
+ 0 - 0
.temp_to_pub/EasySpider_windows_x64/execution_instances/9.json


Datei-Diff unterdrückt, da er zu groß ist
+ 0 - 0
.temp_to_pub/EasySpider_windows_x64/tasks/116.json


+ 1 - 1
.temp_to_pub/EasySpider_windows_x86/软件使用说明.txt

@@ -2,7 +2,7 @@
 
 官方网址: https://www.easyspider.cn
 
-支持Windows 7及以上版本,包括32位系统和64位系统。注意此版本的Chrome浏览器永远都是109不会随着Chrome更新而更新(为了兼容Win 7系统),因此如果想用最新版Chrome浏览器采集数据,请在Windows 10 x64及以上系统上运行x64版本的EasySpider。
+支持Windows 7及以上版本,包括32位系统和64位系统。注意此版本的Chrome浏览器永远都是109不会随着Chrome更新而更新(为了兼容Win 7系统),因此如果想用最新版Chrome浏览器采集数据,请在Windows 10 x64及以上系统上运行x64版本的EasySpider。
 
 视频教程:https://www.bilibili.com/video/BV1th411A7ey/
 

BIN
ElectronJS/EasySpider_en.crx


BIN
ElectronJS/EasySpider_zh.crx


+ 57 - 0
Extension/manifest_v3/src/content-scripts/main.js

@@ -228,6 +228,63 @@ function generateToolkit() {
             $(document).off('mousemove');
         });
     });
+    // 拖拽右下角改变大小
+    const wrapperToolkit = document.getElementById('wrapperToolkit');
+    const EasySpiderResizer = document.getElementById('EasySpiderResizer');
+
+    let mousedown = false;
+    let startX, startY, startWidth, startHeight;
+
+
+    EasySpiderResizer.addEventListener('mousedown', e => {
+        mousedown = true;
+        startX = e.clientX;
+        startY = e.clientY;
+        startWidth = wrapperToolkit.offsetWidth;
+        startHeight = wrapperToolkit.offsetHeight;
+        e.preventDefault();
+    });
+
+    window.addEventListener('mousemove', e => {
+        // if the mouse is not pressed, do nothing
+        if (!mousedown) return;
+        let newX = e.clientX;
+        let newY = e.clientY;
+
+        // Update the width: Original width - (current mouse X position - original mouse X position)
+        let newWidth = startWidth - (newX - startX);
+
+        // Update the height: Original height - (current mouse Y position - original mouse Y position)
+        let newHeight = startHeight - (newY - startY);
+
+        // Set the new width, height and left, top of the wrapperToolkit
+
+
+
+        // wrapperToolkit.style.left = `${newX}px`;
+        // wrapperToolkit.style.top = `${newY}px`;
+
+        if (newWidth > 300 && newWidth < 1200) {
+            wrapperToolkit.style.width = `${newWidth}px`;
+            // set the new width of the wrapperToolkit
+        }
+        if (newHeight > 420 && newHeight < 800) {
+            wrapperToolkit.style.height = `${newHeight}px`;
+            // console.log(newHeight)
+            try{
+                let toolkitcontain = document.getElementsByClassName('toolkitcontain')[0];
+                toolkitcontain.style.height = `${newHeight-330}px`;
+            } catch(e){
+
+            }
+            // set the new width of the wrapperToolkit
+        }
+    });
+
+    window.addEventListener('mouseup', e => {
+        // when the mouse is released, stop resizing
+        mousedown = false;
+    });
     timer = setInterval(function() { //时刻监测相应元素是否存在(防止出现如百度一样元素消失重写body的情况),如果不存在,添加进来
         if (document.body != null && document.getElementsByClassName("tooltips").length == 0) {
             this.clearInterval(); //先取消原来的计时器,再设置新的计时器

+ 9 - 7
Extension/manifest_v3/src/content-scripts/toolkit.vue

@@ -1,7 +1,9 @@
 <template>
   <div id="realcontent">
+<!--    <div id="EasySpiderResizer" style="width: 10px; height: 10px; background-color: black; position: absolute; left: 0; bottom: 0; cursor: ne-resize;"></div>-->
+    <div id="EasySpiderResizer" style="width: 10px; height: 10px; position: absolute; left: 0; top: 0; cursor: nw-resize;"></div>
     <div v-if="lang == 'zh'">
-      <div class="tooldrag">✍操作提示框(可点此拖动)</div>
+      <div class="tooldrag">✍操作台(点此拖动,左上角调整大小)</div>
       <div class="realcontent">
         <div v-if="page==0">
           <div v-if="list.nl.length==0" :style="{overflow: 'auto', maxHeight: winHeight * 0.4 + 'px'}">
@@ -94,7 +96,7 @@
             </div>
           </div>
           <div v-if="valTable.length>0">
-            <div class="toolkitcontain">{{ setWidth("290px") }}
+            <div class="toolkitcontain">
               <table cellSpacing="0" class="toolkittb2">
                 <tbody>
                 <th v-for="(i, index) in list.opp"> <div>{{ i["name"] }}</div> <span v-bind:index="index" v-on:mousedown="removeField" title="删除此字段">×</span> </th>
@@ -115,7 +117,7 @@
             </div>
           </div>
 
-          <div v-if="valTable.length==0&&tname()!='下一页元素'">{{ setWidth("290px") }}</div>
+          <div v-if="valTable.length==0&&tname()!='下一页元素'"></div>
 
           <div v-if="list.nl.length>0"
                style="bottom:12px;position:absolute;color:black!important;left:17px;font-size:13px">
@@ -155,7 +157,7 @@
       </div>
     </div>
     <div v-else-if="lang=='en'">
-      <div class="tooldrag">✍Operation Toolbox (Can drag)</div>
+      <div class="tooldrag">✍Toolbox (Can drag, resize at left corner)</div>
       <div class="realcontent">
         <div v-if="page==0">
           <div v-if="list.nl.length==0" :style="{overflow: 'auto', maxHeight: winHeight * 0.4 + 'px'}">
@@ -255,7 +257,7 @@
           </div>
 
           <div v-if="valTable.length>0">
-            <div class="toolkitcontain">{{ setWidth("350px") }}
+            <div class="toolkitcontain">
               <table cellspacing="0" class="toolkittb2">
                 <tbody>
                 <th v-for="(i, index) in list.opp"><div>{{ i["name"] }}</div> <span v-bind:index="index" v-on:mousedown="removeField" title="Remove this field">×</span> </th>
@@ -275,7 +277,7 @@
             </div>
           </div>
 
-          <div v-if="valTable.length==0&&tname()!='下一页元素'">{{ setWidth("290px") }}</div>
+          <div v-if="valTable.length==0&&tname()!='下一页元素'"></div>
 
           <div v-if="list.nl.length>0"
                style="bottom:12px;position:absolute;color:black!important;left:17px;font-size:13px">
@@ -659,7 +661,7 @@ export default {
       } else if ($(global.nodeList[0]["node"]).contents().filter(function () {
         return this.nodeType === 3;
       }).text().indexOf("下一页") >= 0) {
-        this.setWidth("280px");
+        // this.setWidth("280px");
         return "下一页元素";
       } else if (tag == "A") {
         return "链接";

Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden.