Tho*_*ben 9 python phantomjs selenium-webdriver ghostdriver
如何使用PhantomJS通过Webdriver记录页面加载的所有HTTP请求和响应?我正在使用python,我的超级简单测试脚本如下所示:
from selenium import webdriver
driver = webdriver.PhantomJS()
driver.get('http://www.golem.de')
Run Code Online (Sandbox Code Playgroud)
我已经在PhantomJS中找到了这些功能:
page.onResourceRequested = function (request) {
console.log('Request ' + JSON.stringify(request, undefined, 4));
};
Run Code Online (Sandbox Code Playgroud)
但我不知道如何将它与Selenium Webdriver和Ghostdriver结合在一起.我怎么能这样做?
记录所有网络流量的一种方法是使用出色的工具strace,将所有网络请求(和数据)记录到文件中。
strace -s9999 -e trace=network curl http://example.com > /dev/null
Run Code Online (Sandbox Code Playgroud)
部分输出:
sendto(3, "GET / HTTP/1.1\r\nUser-Agent: curl/7.32.0\r\nHost: example.com\r\nAccept: */*\r\n\r\n", 75, MSG_NOSIGNAL, NULL, 0) = 75
recvfrom(3, "HTTP/1.1 200 OK\r\nAccept-Ranges: bytes\r\nCache-Control: max-age=604800\r\nContent-Type: text/html\r\nDate: Sun, 08 Ju...
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2297 次 |
| 最近记录: |