mcp-query-table 0.3.8__tar.gz → 0.3.9__tar.gz
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.
- {mcp_query_table-0.3.8 → mcp_query_table-0.3.9}/PKG-INFO +2 -3
- {mcp_query_table-0.3.8 → mcp_query_table-0.3.9}/mcp_query_table/__main__.py +1 -1
- mcp_query_table-0.3.9/mcp_query_table/_version.py +1 -0
- {mcp_query_table-0.3.8 → mcp_query_table-0.3.9}/mcp_query_table/sites/iwencai.py +0 -4
- {mcp_query_table-0.3.8 → mcp_query_table-0.3.9}/mcp_query_table/tool.py +5 -1
- {mcp_query_table-0.3.8 → mcp_query_table-0.3.9}/mcp_query_table/utils.py +0 -17
- {mcp_query_table-0.3.8 → mcp_query_table-0.3.9}/pyproject.toml +1 -2
- mcp_query_table-0.3.8/mcp_query_table/_version.py +0 -1
- {mcp_query_table-0.3.8 → mcp_query_table-0.3.9}/.gitignore +0 -0
- {mcp_query_table-0.3.8 → mcp_query_table-0.3.9}/LICENSE +0 -0
- {mcp_query_table-0.3.8 → mcp_query_table-0.3.9}/README.md +0 -0
- {mcp_query_table-0.3.8 → mcp_query_table-0.3.9}/mcp_query_table/__init__.py +0 -0
- {mcp_query_table-0.3.8 → mcp_query_table-0.3.9}/mcp_query_table/enums.py +0 -0
- {mcp_query_table-0.3.8 → mcp_query_table-0.3.9}/mcp_query_table/providers/__init__.py +0 -0
- {mcp_query_table-0.3.8 → mcp_query_table-0.3.9}/mcp_query_table/providers/baidu.py +0 -0
- {mcp_query_table-0.3.8 → mcp_query_table-0.3.9}/mcp_query_table/providers/n.py +0 -0
- {mcp_query_table-0.3.8 → mcp_query_table-0.3.9}/mcp_query_table/providers/yuanbao.py +0 -0
- {mcp_query_table-0.3.8 → mcp_query_table-0.3.9}/mcp_query_table/server.py +0 -0
- {mcp_query_table-0.3.8 → mcp_query_table-0.3.9}/mcp_query_table/sites/__init__.py +0 -0
- {mcp_query_table-0.3.8 → mcp_query_table-0.3.9}/mcp_query_table/sites/eastmoney.py +0 -0
- {mcp_query_table-0.3.8 → mcp_query_table-0.3.9}/mcp_query_table/sites/tdx.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mcp_query_table
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.9
|
|
4
4
|
Summary: query table from website, support MCP
|
|
5
5
|
Author-email: wukan <wu-kan@163.com>
|
|
6
6
|
License: MIT License
|
|
@@ -33,8 +33,7 @@ Requires-Dist: loguru
|
|
|
33
33
|
Requires-Dist: mcp
|
|
34
34
|
Requires-Dist: pandas
|
|
35
35
|
Requires-Dist: playwright
|
|
36
|
-
Requires-Dist: playwright-stealth
|
|
37
|
-
Requires-Dist: setuptools
|
|
36
|
+
Requires-Dist: playwright-stealth>=2.0.0
|
|
38
37
|
Requires-Dist: tabulate
|
|
39
38
|
Description-Content-Type: text/markdown
|
|
40
39
|
|
|
@@ -17,7 +17,7 @@ def main():
|
|
|
17
17
|
parser.add_argument("--executable_path", type=str, help="浏览器路径",
|
|
18
18
|
nargs="?", default=r'C:\Program Files\Google\Chrome\Application\chrome.exe')
|
|
19
19
|
parser.add_argument("--user_data_dir", type=str, help="浏览器用户数据目录",
|
|
20
|
-
nargs="?", default=rf'C:\Users\{getpass.getuser()}\AppData\Local\Google\Chrome\User Data')
|
|
20
|
+
nargs="?", default=rf'C:\Users\{getpass.getuser()}\AppData\Local\Google\Chrome\User Data\Default')
|
|
21
21
|
parser.add_argument("--transport", type=str, help="传输类型",
|
|
22
22
|
default='stdio', choices=['stdio', 'sse'])
|
|
23
23
|
parser.add_argument("--host", type=str, help="MCP服务端绑定地址",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.3.9"
|
|
@@ -10,10 +10,8 @@ import re
|
|
|
10
10
|
import pandas as pd
|
|
11
11
|
from loguru import logger
|
|
12
12
|
from playwright.async_api import Page
|
|
13
|
-
from playwright_stealth import stealth_async
|
|
14
13
|
|
|
15
14
|
from mcp_query_table.enums import QueryType
|
|
16
|
-
from mcp_query_table.utils import FixedConfig
|
|
17
15
|
|
|
18
16
|
# 初次查询页面
|
|
19
17
|
_PAGE1_ = 'https://www.iwencai.com/customized/chart/get-robot-data'
|
|
@@ -154,8 +152,6 @@ async def query(page: Page,
|
|
|
154
152
|
querytype = _querytype_.get(type_, None)
|
|
155
153
|
assert querytype is not None, f"不支持的类型:{type_}"
|
|
156
154
|
|
|
157
|
-
await stealth_async(page, FixedConfig())
|
|
158
|
-
|
|
159
155
|
await page.route(re.compile(r'.*\.(?:jpg|jpeg|png|gif|webp)(?:$|\?)'), lambda route: route.abort())
|
|
160
156
|
|
|
161
157
|
P.reset()
|
|
@@ -4,11 +4,12 @@ import sys
|
|
|
4
4
|
import time
|
|
5
5
|
from pathlib import Path
|
|
6
6
|
from typing import Optional
|
|
7
|
-
from urllib.parse import urlparse
|
|
7
|
+
from urllib.parse import urlparse, quote
|
|
8
8
|
|
|
9
9
|
import pandas as pd
|
|
10
10
|
from loguru import logger
|
|
11
11
|
from playwright.async_api import async_playwright, Playwright, Page
|
|
12
|
+
from playwright_stealth import Stealth
|
|
12
13
|
|
|
13
14
|
from mcp_query_table.enums import QueryType, Site, Provider
|
|
14
15
|
|
|
@@ -204,6 +205,8 @@ class BrowserManager:
|
|
|
204
205
|
self.context = await self.browser.new_context()
|
|
205
206
|
else:
|
|
206
207
|
self.context = self.browser.contexts[0]
|
|
208
|
+
# 爱问财,无头模式,需要使用 stealth 插件
|
|
209
|
+
await Stealth().apply_stealth_async(self.context)
|
|
207
210
|
|
|
208
211
|
# 复用打开的page
|
|
209
212
|
for page in self.context.pages:
|
|
@@ -268,6 +271,7 @@ async def query(
|
|
|
268
271
|
查询结果
|
|
269
272
|
|
|
270
273
|
"""
|
|
274
|
+
query_input = quote(query_input.strip(), safe='')
|
|
271
275
|
|
|
272
276
|
if site == Site.EastMoney:
|
|
273
277
|
from mcp_query_table.sites.eastmoney import query
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import random
|
|
2
|
-
import string
|
|
3
1
|
from pathlib import Path
|
|
4
2
|
from typing import List, Tuple
|
|
5
3
|
|
|
6
|
-
from playwright_stealth import StealthConfig
|
|
7
|
-
|
|
8
4
|
|
|
9
5
|
def is_image(path: str) -> bool:
|
|
10
6
|
"""判断是否是图片文件"""
|
|
@@ -36,16 +32,3 @@ class GlobalVars:
|
|
|
36
32
|
|
|
37
33
|
def get_text(self):
|
|
38
34
|
return self.text
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
# https://github.com/AtuboDad/playwright_stealth/issues/31#issuecomment-2342541305
|
|
42
|
-
class FixedConfig(StealthConfig):
|
|
43
|
-
|
|
44
|
-
@property
|
|
45
|
-
def enabled_scripts(self):
|
|
46
|
-
key = "".join(random.choices(string.ascii_letters, k=10))
|
|
47
|
-
for script in super().enabled_scripts:
|
|
48
|
-
if "const opts" in script:
|
|
49
|
-
yield script.replace("const opts", f"window.{key}")
|
|
50
|
-
continue
|
|
51
|
-
yield script.replace("opts", f"window.{key}")
|
|
@@ -16,9 +16,8 @@ dependencies = [
|
|
|
16
16
|
"pandas",
|
|
17
17
|
"loguru",
|
|
18
18
|
"playwright",
|
|
19
|
-
"playwright-stealth",
|
|
19
|
+
"playwright-stealth>=2.0.0", # https://github.com/Mattwmaster58/playwright_stealth
|
|
20
20
|
"mcp",
|
|
21
|
-
"setuptools", # playwright-stealth中要使用pkg_resources,而pkg_resources在setuptools中
|
|
22
21
|
"tabulate"
|
|
23
22
|
]
|
|
24
23
|
dynamic = ["version"]
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.3.8"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|