From c262a978f7f3589cf68917e70a0ff4fb53e68533 Mon Sep 17 00:00:00 2001 From: g1879 Date: Fri, 1 Jan 2021 01:21:29 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9F=A5=E6=89=BE=E5=85=83=E7=B4=A0=E8=AF=AD?= =?UTF-8?q?=E5=8F=A5=E5=A2=9E=E5=8A=A0=E8=B6=85=E7=AE=80=E6=B4=81=E6=96=B9?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DrissionPage/common.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/DrissionPage/common.py b/DrissionPage/common.py index f7a4d06..ce90222 100644 --- a/DrissionPage/common.py +++ b/DrissionPage/common.py @@ -113,6 +113,18 @@ def str_to_loc(loc: str) -> tuple: else: loc = loc.replace('#', '@id=', 1) + if loc.startswith(('x:', 'x=')): + loc = f'xpath:{loc[2:]}' + + if loc.startswith(('c:', 'c=')): + loc = f'css:{loc[2:]}' + + if loc.startswith(('t:', 't=')): + loc = f'tag:{loc[2:]}' + + if loc.startswith(('tx:', 'tx=')): + loc = f'text{loc[2:]}' + # 根据属性查找 if loc.startswith('@'): r = re_SPLIT(r'([:=])', loc[1:], maxsplit=1)