简体   繁体   English

获取浏览器呈现的 java 中完全加载的网页源代码

[英]Get completely loaded webpage sourcecode in java as rendered by browser

There are few webpage which employs some javascript/ajax calls to fill some fields in webpage during page load or after page load.很少有网页在页面加载期间或页面加载后使用一些 javascript/ajax 调用来填充网页中的某些字段。 One example is http://www.sohos.co.uk/MEN-T-Shirts/Iron-Fist-Mens-Clothing/--Iron-Fist-Bloody-Mess-T--Shirt_ct271bd5pd197.html where content in size drop down box is filled by use of javascript.一个例子是http://www.sohos.co.uk/MEN-T-Shirts/Iron-Fist-Mens-Clothing/--Iron-Fist-Bloody-Mess-T--Shirt_ct271bd5pd197.ZFC35FDC70D5FC69D269883A822C7A内容尺寸使用 javascript 填充向下框。

Is it possible to get fully loaded page of this type in Java?是否有可能在 Java 中获得这种类型的完全加载页面? I think, simply using HttpClient or other methods will not suffice but using Selenium, if this can be done, it would be really great.我想,单纯使用HttpClient或者其他方式是不行的,使用Selenium,如果能做到,那就太好了。

I want some generic solution which could be applied for all websites.我想要一些适用于所有网站的通用解决方案。

Any input/pointers would be greatly appreciated.任何输入/指针将不胜感激。

Thanks谢谢

Jitendra日滕德拉

Selenium's WebDriver supports such emulation through different implementations. Selenium 的WebDriver通过不同的实现支持这种模拟。 One of which is HtmlUnit (a headless java browser) - take a look.其中之一是HtmlUnit (无头 java 浏览器) - 看看。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM