gpt4 book ai didi

java - HtmlUnit 修改传出请求吗?如何?

转载 作者:行者123 更新时间:2023-12-02 07:47:04 24 4
gpt4 key购买 nike

我正在尝试在发送 HtmlUnit 发出的请求之前对其进行修改,我进行了大量的谷歌搜索并在他们的常见问题解答中找到了这一点

http://htmlunit.sourceforge.net/faq.html#HowToModifyRequestOrResponse

How to modify the outgoing request or incoming response? You can subclass HttpWebConnection and override getResponse() as:

    new WebConnectionWrapper(webClient) {

public WebResponse getResponse(WebRequest request) throws IOException {
WebResponse response = super.getResponse(request);
// modify the response by creating a new WebResponse
return response;
}
};

我尝试在单击提交按钮后修改请求,如下例所示

page = submitButtonSend.click();

应该如何编写,以便我可以在发出请求之前对其进行修改?

最佳答案

public WebResponse getResponse(WebRequest request) throws IOException {
modifyRequest(request);
return super.getResponse(request);
}

关于java - HtmlUnit 修改传出请求吗?如何?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10674923/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com