Python 进入一个网站并运行 $(document).ready(function()
Python Get on a website and running $(document).ready(function()
我正在我的网站上做一些测试,我有一个python程序,它可以在几个不同的页面上出现。其中一些页面有 $(document).ready(function()
.我注意到当我通过python时,我得到了代码,但例如$(document).ready(function()
没有运行。
如何运行我正在执行 GET 的网站的$(document).ready(function()
?
谢谢你的帮助。
你应该选择Selenium,它让你从你的python代码控制一个真正的浏览器。这意味着您的 javascript 将由浏览器执行。
示例代码:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver = webdriver.Firefox()
driver.get("http://www.python.org")
assert "Python" in driver.title
elem = driver.find_element_by_name("q")
elem.send_keys("pycon")
elem.send_keys(Keys.RETURN)
assert "No results found." not in driver.page_source
driver.close()
相关文章:
- 为什么一个 $(document).ready(function() { 会阻止另一个运行
- 无法运行php函数来使用document.write更新db值
- 如何在document.ready(function)时运行隐藏函数和动画
- 如何在document.getElementsByClassName中对类的特定选择器运行函数
- 在document.ready jquery上运行ajax请求
- UIWebView 无法将 JavaScript 作为 document.getElementById 运行,返回 nu
- 为什么 document.onreadystatechange 运行两次
- document.ready 即使加载了 window.load 也会运行
- Python 进入一个网站并运行 $(document).ready(function()
- 使用getElementsByTagName运行包含document.write的脚本
- 重新运行$(document).ready()
- 如何调用我的jQuery函数,使其在我的document.ready函数中运行
- Backbone.marionette:jQuery document.ready未在路线上运行
- 我的代码是在$document.ready中调用的,但似乎是在加载DOM之前运行的.为什么?
- 如何根据JavaScript的需求而不是在(document).ready上运行jQuery函数
- 运行函数时:窗口.滚动,窗口.调整,document.ready
- 运行mocha测试,但得到错误:ReferenceError: document没有定义
- 淘汰嵌套组件:$(document).ready() ..在加载嵌套组件之前运行
- 使用"document.write"运行javascript调用一个jQuery创建的DIV
- Document.ready()只运行一个函数而不是两个