python上的虚拟助手

时间:2021-05-10 18:59:05

标签: python python-3.x bots virtual pyautogui

所以我在 Python 上制作了一个虚拟机器人,在添加一个功能时,我产生了这个疑问。 所以就像当我告诉它打开亚马逊时,它打开亚马逊网站并询问我想搜索什么,当我告诉它在搜索栏中输入我说的内容并按 Enter 然后单击评级为 4 星及以上,然后下一部分就像它问我我的预算是多少,以便它可以在过滤器中填充它,这就是问题出现的地方......就像,假设我说我的预算是 50000 它去到过滤器中的“最大”框并用“五万”之类的词键入 50000 那么有什么办法可以让它用数字而不是词来键入吗??

这是代码的那部分:

elif "jarvis open amazon" in query:
            speak("opening amazon.com")
            webbrowser.open("https://www.amazon.in/")
            speak("would you want to search for something?")
            amaz = takeCommand().lower()
            if amaz == 'yes':
                speak("what would you like to search for?")
                res = takeCommand().lower()
                pyautogui.moveTo(700, 225)
                pyautogui.typewrite(res)
                pyautogui.typewrite(["enter"])
                pyautogui.sleep(3)
                pyautogui.moveTo(pyautogui.locateCenterOnScreen("amaz rating.png"))
                pyautogui.sleep(1)
                pyautogui.click()
                pyautogui.sleep(2)
                speak("is there any maximum budget that you ant to set?")
                itmb = takeCommand().lower()
                if itmb == "yes":
                    speak("ok, what is your maximum budget?")
                    wymb = takeCommand().lower()
                    pyautogui.scroll(-300)
                    pyautogui.moveTo(pyautogui.locateCenterOnScreen("amaz max.png"))
                    pyautogui.click()
                    pyautogui.typewrite(wymb)
                    pyautogui.moveTo(pyautogui.locateCenterOnScreen("amaz go.png"))
                    pyautogui.sleep(1)
                    pyautogui.click()

“amaz rating.png”是 4star 及以上评级的 ss,“amaz max.png”是亚马逊过滤器中最大框的 ss,“amaz go”是旁边的 go 按钮最大按钮。

0 个答案:

没有答案