简体   繁体   English

Python中的Browser()在IDLE中显示错误

[英]Browser() in Python shows errors in IDLE

I have some code here which is basically a bot that spams a specific google form: 我在这里有一些代码,基本上是一个向特定Google表单发送垃圾邮件的机器人:

while True:
    browser = Browser()
    print("Form Filling Begun")
    browser.visit('https://docs.google.com/forms/d/1Lyoox1FIpOP5nceVHqmdA3Exqf8PMCxaBgWIYQ67yX8/viewform?c=0&w=1')
    browser.fill('entry.1796849606', 'test')
    browser.fill('entry.1233774681', 'test')
    browser.fill('entry.1687034525', 'test')
    browser.fill('entry.2085519362', 'test')
    browser.fill('entry.2085519362', 'test')
    browser.fill('entry.87435301', 'test')
    browser.find_by_name('entry.434307791', 'test')
    browser.find_by_name('submit').click()
    print("Form Filled")
    browser.quit()
    time.sleep(10)

When I ran it in IDLE, it said there was a problem on line 2. That Browser() wasn't defined. 当我在IDLE中运行它时,它说在第2行存在问题。未定义Browser()。 Now, I know that my friend was able to accomplish this with this code, so I'm not sure what's wrong. 现在,我知道我的朋友可以使用此代码完成此操作,因此我不确定出什么问题。 I'm sure it's a really basic problem, but I'm a complete n00b at Python, so I don't really know what to do. 我确定这是一个非常基本的问题,但是我在Python上是一个完整的n00b,所以我真的不知道该怎么办。

Thanks, 谢谢,

Sam. 山姆

EDIT: So I went on the Splinter website and put its own sample code in IDLE, to see what happens and this is what the console was showing 编辑:所以我去了Splinter网站,并将其自己的示例代码放在IDLE中,以查看发生了什么,这就是控制台显示的内容

Traceback (most recent call last):
  File "C:/Users/Sam/Desktop/test.py", line 3, in <module>
    with Browser() as browser:
  File "C:\Python27\lib\site-packages\splinter\browser.py", line 63, in Browser
    return driver(*args, **kwargs)
  File "C:\Python27\lib\site-packages\splinter\driver\webdriver\firefox.py", line 39, in __init__
    self.driver = Firefox(firefox_profile)
  File "C:\Python27\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 82, in __init__
    keep_alive=True)
  File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 87, in __init__
    self.start_session(desired_capabilities, browser_profile)
  File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 141, in start_session
    'desiredCapabilities': desired_capabilities,
  File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 201, in execute
    self.error_handler.check_response(response)
  File "C:\Python27\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 193, in check_response
    raise exception_class(message, screen, stacktrace)
WebDriverException: Message: a.addEventListener is not a function

I'm out of my depth here. 我不在这里。 When it opened a browser window, the URL was about:blank&utm_content=firstrun . 打开浏览器窗口时,URL为about:blank&utm_content=firstrun What does that mean?? 这意味着什么??

Do you import browser? 您导入浏览器吗? Try: 尝试:

from splinter.browser import Browser

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM