[英]Load page content without reloading the whole page
import selenium
driver = webdriver.Firefox()
url='web.whatsapp.com'
driver.get(url)
for i in range (0,10):
url=https://web.whatsapp.com/send?phone=9178XXX53439&text=hello
driver.get(URL)
its reload the whole page every time.它每次都重新加载整个页面。
I want to change page content while this loop call URL without reloading page.我想在此循环调用 URL 而不重新加载页面时更改页面内容。 I change this url=https://web.whatsapp.com/send?phone=9178XXX53439&text=hello every time.我每次都更改此 url=https://web.whatsapp.com/send?phone=9178XXX53439&text=hello 。
You can load content in background using ajax in Javascript.您可以使用 Javascript 中的 ajax 在后台加载内容。 Try this demo https://www.w3schools.com/xml/ajax_intro.asp试试这个演示https://www.w3schools.com/xml/ajax_intro.asp
<html>
<body>
<div id="demo">
<h1>The XMLHttpRequest Object</h1>
<button type="button" onclick="loadDoc()">Change Content</button>
</div>
<script>
function loadDoc() {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("demo").innerHTML =
this.responseText;
}
};
xhttp.open("GET", "ajax_info.txt", true);
xhttp.send();
}
</script>
</body>
</html>```
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.