I'am using jxbrowser,
This code loads one URL in one browser and saves it's page .
public class JxBrowserDemo {
public JxBrowserDemo(String url) {
Browser browser = new Browser();
browser.addLoadListener(new LoadAdapter() {
@Override
public void onFinishLoadingFrame(FinishLoadingEvent event) {
if (event.isMainFrame()){
String filePath = "G:\\Test\\index"+System.currentTimeMillis()+".html";
String dirPath = "G:\\Test\\resources";
event.getBrowser().saveWebPage(filePath, dirPath, SavePageType.COMPLETE_HTML);
}
}
});
browser.loadURL(url);
if(!browser.isLoading())
{
browser.dispose();
}
}
public static void main(String args[])
{
JxBrowserDemo jxBrowserDemo=new JxBrowserDemo("www.google.com");
}
}
could I load more than URL in the same browser and save it's pages in Local Path ?
Thanks In advance ............
You can load one by one as many URLs as you want and save these web pages by the saveWebPage()
method in the same browser.
You should completely load the web page, invoke the saveWebPage()
method, wait until the web page is saved, and then repeat these actions with the next URL.
The dispose()
method should be invoked when you don't need to perform any actions with this browser instance.