开发者

In htmlunit, how can I get the request, that would be sent on clicking an element?

开发者 https://www.devze.com 2022-12-16 17:33 出处:网络
I want to find a way to get the settings of the request that would be sent if I clicked a certain link. I want to send the request after making some开发者_高级运维 modifications. Is that possible?

I want to find a way to get the settings of the request that would be sent if I clicked a certain link. I want to send the request after making some开发者_高级运维 modifications. Is that possible?

Answering the comments, right now I want to change the headers sent, but post values or target url may be of interest too. I want to grab the request before it is sent, modify it and send.


You can subclass HttpWebConnection and manipulate the 'settings', as in:

    webClient.setWebConnection(new HttpWebConnection(webClient) {
        public WebResponse getResponse(WebRequestSettings settings) throws IOException {
            System.out.println(settings.getUrl());
            return super.getResponse(settings);
        }
    });
0

精彩评论

暂无评论...
验证码 换一张
取 消