点击与蟒蛇一个网上JS按钮 [英] Clicking in a online js button with python
本文介绍了点击与蟒蛇一个网上JS按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试着点击搜索的所有航班按钮,在 http://www.priceline.com/ 但我有一些问题。
I'm trying to click on the "Search all flights" button in http://www.priceline.com/ but i'm having some problems.
我知道,机械化不能用JavaScript工作,所以我尝试了一下就源$ C $ C试图做的按钮做什么,但我不能找到函数。
有任何其他方式做到这一点?
I know that mechanize doesn't work with javascript so I tried so look on the source code trying to do what the button does but i can't find the function. There's any other way to do this?
推荐答案
我建议使用硒
(下载链接),这对JavaScript的非常沉重的支持。 这里所有文档。
I suggest using selenium
(download link), which has very heavy support for javascript. All docs here.
下面是你如何能做到这一个简单的例子:
Here is a quick example of how you can do that:
from selenium import webdriver
driver = webdriver.Firefox()
driver.get("http://www.priceline.com/")
driver.find_element_by_id("hotel-btn-submit-retl").click()
driver.close()
这篇关于点击与蟒蛇一个网上JS按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文