[英]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)
它每次都重新加載整個頁面。
我想在此循環調用 URL 而不重新加載頁面時更改頁面內容。 我每次都更改此 url=https://web.whatsapp.com/send?phone=9178XXX53439&text=hello 。
您可以使用 Javascript 中的 ajax 在后台加載內容。 試試這個演示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.