-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
同花顺防自动交易跟防贼似的,在持仓界面复制和保存都要验证码了 #452
Comments
借助外部程序识别验证码,大约80%以上的成功率 --- a/easytrader/grid_strategies.py
+++ b/easytrader/grid_strategies.py
@@ -97,7 +97,7 @@ class Copy(BaseStrategy):
def _get_clipboard_data(self) -> str:
if Copy._need_captcha_reg:
if (
- self._trader.app.top_window().window(class_name="Static", title_re="验证码").exists(timeout=1)
+ self._trader.app.top_window().window(class_name="Static", title_re=".*验证码.*").exists(timeout=1)
):
file_path = "tmp.png"
count = 5
@@ -108,17 +108,14 @@ class Copy(BaseStrategy):
).capture_as_image().save(
file_path
) # 保存验证码
-
captcha_num = captcha_recognize(file_path).strip() # 识别验证码
captcha_num = "".join(captcha_num.split())
logger.info("captcha result-->" + captcha_num)
if len(captcha_num) == 4:
- self._trader.app.top_window().window(
- control_id=0x964, class_name="Edit"
- ).set_text(
- captcha_num
- ) # 模拟输入验证码
-
+ editor = self._trader.app.top_window().child_window(control_id=0x964, class_name="Edit")
+ editor.select()
+ editor.type_keys(captcha_num)
+ self._trader.app.top_window().set_focus()
self._trader.app.top_window().set_focus()
pywinauto.keyboard.SendKeys("{ENTER}") # 模拟发送enter,点击确定
try:
@@ -184,6 +181,21 @@ class Xls(BaseStrategy):
count = 10
while count > 0:
if self._trader.is_exist_pop_dialog():
+ if self._trader._app.top_window().window(class_name="Static", title_re=".*验证码.*") != None:
+ file_path = "tmp.png"
+ self._trader.app.top_window().window(
+ class_name="Static", control_id=0x965
+ ).capture_as_image().save(file_path)
+ captcha_num = captcha_recognize(file_path).strip() # 识别验证码
+ captcha_num = "".join(captcha_num.split())
+ logger.info("captcha result-->" + captcha_num)
+ if len(captcha_num) == 4:
+ editor = self._trader.app.top_window().child_window(control_id=0x964, class_name="Edit")
+ editor.select()
+ editor.type_keys(captcha_num)
+ self._trader.app.top_window().set_focus()
+ pywinauto.keyboard.send_keys("{ENTER}") # 模拟发送enter,点击确定
+ self._trader.wait(1)
break
self._trader.wait(0.2)
count -= 1 |
就是,像防贼一样 |
您好,请问您可以把您修改的文件grid_strategies.py完整上传吗? |
请问有人可以提供援助吗,目前卡这儿了 |
我这边代码修改的很乱,尤其是延时这块。就不折腾了 |
请问一下,是不是只有同花顺需要验证码,其他券商还要验证码吗 |
验证码很容易解决 |
+1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
env
OS: win7/ win10 / mac / linux
PYTHON_VERSION: 3.x
EASYTRADER_VERSION: 0.xx.xx
BROKER_TYPE: gj / ht / xq / xxx
problem
how to repeat
The text was updated successfully, but these errors were encountered: