- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想获取网页所有网络调用的列表。这是页面的网址
https://www.upwork.com/o/jobs/browse/?q=Java&sort=renew_time_int%2Bdesc
如果查看 DeveloperConsole->Network,您将看到以下列表
这是我的代码:
public static void main(String[] args) throws IOException {
final WebClient webClient = configWebClient();
final List<String> list = new ArrayList<>();
new WebConnectionWrapper(webClient) {
@Override
public WebResponse getResponse(final WebRequest request) throws IOException {
final WebResponse response = super.getResponse(request);
list.add(request.getUrl().toString());
return response;
}
};
webClient.getPage("https://www.upwork.com/ab/find-work/");
list.forEach(System.out::println);
}
private static WebClient configWebClient() {
WebClient webClient = new WebClient(BrowserVersion.FIREFOX_60);
webClient.getOptions().setJavaScriptEnabled(true);
webClient.waitForBackgroundJavaScriptStartingBefore(5_000);
webClient.waitForBackgroundJavaScript(3_000);
webClient.getOptions().setCssEnabled(false);
webClient.getOptions().setRedirectEnabled(true);
webClient.getOptions().setUseInsecureSSL(false);
webClient.getOptions().setThrowExceptionOnFailingStatusCode(false);
webClient.getOptions().setThrowExceptionOnScriptError(false);
webClient.getCookieManager().setCookiesEnabled(true);
webClient.setAjaxController(new AjaxController());
webClient.getOptions().setThrowExceptionOnScriptError(false);
webClient.getCookieManager().setCookiesEnabled(true);
return webClient;
}
这是输出
https://www.upwork.com/o/jobs/browse/?q=Java&sort=renew_time_int%2Bdesc
https://www.upwork.com/o/jobs/browse/?q=Java
https://www.upwork.com:443/o/jobs/browse/js/328ecc3.js?4af40b2
https://www.googletagmanager.com/gtm.js?id=GTM-5XK7SV
https://client.perimeterx.net/PXSs13U803/main.min.js
https://assets.static-upwork.com/components/11.4.0/core.11.4.0.air2.min.js
https://assets.static-upwork.com/global-components/@latest/ugc.js
https://assets.static-upwork.com/global-components/@latest/ugc/ugc.6jcmqb32.js
https://www.upwork.com:443/static/jsui/JobSearchUI/assets/4af40b2/js/55260a3.js
如您所见,它不包含 xhr 调用。我做错了什么?
最佳答案
您的问题使用两个不同的 URL;希望我用对了
使用 HtmlUnit 时调用页面似乎会产生一些 js 错误。也许这会导致无法执行该页面中的所有 javascript 代码(HtmlUnit (Rhino) 仍然不支持一些 javascript 功能;欢迎任何帮助)
public static void main(String[] args) throws IOException {
final WebClient webClient = new WebClient(BrowserVersion.FIREFOX_60);
webClient.getOptions().setThrowExceptionOnScriptError(false);
final List<String> list = new ArrayList<>();
new WebConnectionWrapper(webClient) {
@Override
public WebResponse getResponse(final WebRequest request) throws IOException {
final WebResponse response = super.getResponse(request);
list.add(request.getHttpMethod() + " " + request.getUrl());
return response;
}
};
webClient.getPage("https://www.upwork.com/o/jobs/browse/?q=Java&sort=renew_time_int%2Bdesc");
webClient.waitForBackgroundJavaScript(10_000);
list.forEach(System.out::println);
}
关于java - 如何使用 HtmlUnit 显示所有 AJAX 请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52219615/
htmlunit 报告从 css 到页面上解析错误的所有内容。 这个怎么静音?? 最佳答案 把这些放在声明 webClient 之后 webClient.setCssError
可能显示 Javascript 测试支持 package htmlunitpoc; import com.gargoylesoftware.htmlunit.WebClient; import co
我正在尝试使用 HtmlUnit 登录到我的本地 wordpress 网站,但它似乎存在 cookie 问题。 那是代码的开头: WebClient webClient = new WebClient
有什么办法可以在 HtmlUnit 中使用 session 更改 url? 我的情况如下所示, 登录 http://test.raja.com与凭据。 获取页面http://home.raja.com
我有以下代码: WebClient webClient = new WebClient(); HtmlPage page = webClient.getPage("http://www.myland.
我研究过htmlunit、httpunit、jwebunit、selenium等ui测试工具。 我对测试工具不是很熟悉。 Htmlunit 在 javascript 支持方面听起来是个不错的选择。然后
我拥有的页面对象是 click() 长链的结果调用(以防万一您想知道如何在不知道用于获取它的 URL 的情况下拥有一个页面对象)。 方法HtmlPage.getDocumentURI未实现。 Html
这是我要抓取的页面:https://www.tokopedia.com/berkahcell2/promo-termurah-vr-virtual-reality-box-v-2-0-remote-b
关闭。这个问题是off-topic .它目前不接受答案。 想改进这个问题吗? Update the question所以它是on-topic用于堆栈溢出。 关闭 10 年前。 Improve thi
我的站点结构看起来像这样: Item 1 Desc 1
我的代码是这样的: WebClient webClient = new WebClient(BrowserVersion.CHROME); webClient.setAjaxController(ne
我只希望页面的文本内容,并且希望抓取尽可能轻巧。我可以关闭HTMLUnit开箱即用的所有JavaScript和CSS以及其他外部内容的解析和其他加载功能吗? 最佳答案 我认为与您正在寻找的最接近的东西
我有一个提交按钮,但无法点击.. Send SMS 我已经尝试过这个: page = (HtmlPage) form.getInputByValue("Send SMS").click()
我使用 HtmlUnit 对我的网站进行自动化测试。我的网站使用 gmaps api - 发送外部网站请求需要花费大量时间(我有数百次测试和数千次页面加载)。 我需要一些方法来告诉 HtmlUnit
我使用 HtmlUnit 对我的网站进行自动化测试。我的网站使用 gmaps api - 发送外部网站请求需要花费大量时间(我有数百次测试和数千次页面加载)。 我需要一些方法来告诉 HtmlUnit
我正在使用 HtmlUnit 加载一个充满 JavaScript 的网页。 WebClient 可以很好地执行 JavaScript。 但是,当我单击调用 Ajax 调用的特定表单上的按钮时,即使调用
我正在尝试使用 HtmlUnit 登录 Facebook 页面并查看其 HTML 内容。我正在尝试通过 HtmlUnit 填写登录凭据,但在单击提交按钮时我没有看到正在执行的 session 。 在
Hy...我想使用 HtmlUnit 登录到一些 3rd 方网站。但是 HtmlUnit 应该能够告诉我对输入站点的登录尝试是否成功。有什么办法可以使用 HtmlUnit 执行此任务。请帮忙 ..!!
我正在从 selenium-1 升级到 selenium-2 并尝试新的 HtmlUnit 驱动程序。我已经尝试了一些基本的测试(打开一个页面,get_text,..),它似乎 极慢(我认为 chro
我正在使用 HTMLUnit。我正在访问页面,但是特殊(马耳他)字符显示错误。例如,ġuvni 显示为 ?uvni HtmlPage page = submit_button.click(); Sys
我是一名优秀的程序员,十分优秀!