在IDLE中显示错误

在IDLE中显示错误

本文介绍了Python中的Browser()在IDLE中显示错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这里有一些代码,基本上是一个向特定Google表单发送垃圾邮件的机器人:

I have some code here which is basically a bot that spams a specific google form:

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)

当我在IDLE中运行它时,它说第2行存在问题.未定义Browser().现在,我知道我的朋友可以使用此代码完成此操作,因此我不确定出什么问题.我敢肯定这是一个非常基本的问题,但是我在Python上是一个完整的n00b,所以我真的不知道该怎么办.

When I ran it in IDLE, it said there was a problem on line 2. That Browser() wasn't defined. 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.

谢谢

山姆.

所以我进入了Splinter网站,并将其自己的示例代码放在IDLE中,以查看发生了什么,这就是控制台显示的内容

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

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

我不在这里.打开浏览器窗口时,URL为about:blank&utm_content=firstrun.这是什么意思?

I'm out of my depth here. When it opened a browser window, the URL was about:blank&utm_content=firstrun. What does that mean??

推荐答案

是否导入浏览器?试试:

Do you import browser?Try:

from splinter.browser import Browser

这篇关于Python中的Browser()在IDLE中显示错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-03 17:03