Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/286.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 打开网页,然后单击背景中的坐标_Python_Python 2.7_Beautifulsoup - Fatal编程技术网

Python 打开网页,然后单击背景中的坐标

Python 打开网页,然后单击背景中的坐标,python,python-2.7,beautifulsoup,Python,Python 2.7,Beautifulsoup,我试图模拟一个打开的网页,然后在特定的坐标集上发送鼠标点击 我希望此事件在后台进行,而不实际打开浏览器或移动鼠标 例如,打开www.google.com并单击submit(作为一组坐标),而不在屏幕上实际打开站点 这可能吗 编辑:网站也可能包含javascript,我建议使用。 您需要下载或webdriver才能开始 下面是一个骨架示例: from selenium import webdriver # Create a new instance of the Chrome driver dr

我试图模拟一个打开的网页,然后在特定的坐标集上发送鼠标点击

我希望此事件在后台进行,而不实际打开浏览器或移动鼠标

例如,打开www.google.com并单击submit(作为一组坐标),而不在屏幕上实际打开站点

这可能吗

编辑:网站也可能包含javascript,我建议使用。
您需要下载或webdriver才能开始

下面是一个骨架示例:

from selenium import webdriver

# Create a new instance of the Chrome driver
driver = webdriver.Chrome('C:\chromedriver\chromedriver.exe')

# go to the google
driver.get("http://www.google.com")

# click stuff using xpath
driver.find_element_by_xpath('//*[@id="lst-ib"]').click()

# click stuff using coordinates
elem = find_element_by_selector(selector)
ac = ActionChains(browser)
ac.move_to_element(elem).move_by_offset(x_off, y_off).click().perform()

driver.quit()

不确定,但也许这会有所帮助:谢谢,我觉得这是我需要走的方向。我需要编辑我的原始帖子,因为我需要它来处理java脚本。是一个用于自动化浏览器的库。您可以在上述注释中提到的无头模式下运行浏览器。