有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

posthtml获取posthtml代码(在JavaEclipse中)

我正在寻找一种方法来获取呈现的网页的PostHTML代码。在Firefox中有一个名为WebDeveloper的插件,它不仅可以返回“普通”源代码,还可以返回呈现的源代码

示例:https://bs.chregister.ch/cr-portal/auszug/auszug.xhtml?uid=CHE-230.467.384#

我需要获得这个网站的HTML源代码,其中包括地址等内容(在本例中为“c/o Nora Stähelin”和“Kraftstr.1”)。我的代码如下所示:

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class Automation {    
    public static void main(String[] args) {
        String exePath = "src\\seleniumAutomation\\resources\\chromedriver.exe";
        System.setProperty("webdriver.chrome.driver", exePath);

        WebDriver driver = new ChromeDriver();
        String URL = "https://bs.chregister.ch/cr-portal/auszug/auszug.xhtml?uid=CHE-230.467.384#";
        driver.get(URL);

        // get PRE SourceCode
        String pageSource = driver.getPageSource();
        System.out.println(pageSource);

        // get POST SourceCode (containing content)
        // TODO 

        // close window
        driver.quit();      
    }
}

编辑:生成的HTML是指JavaScript更改DOM后的HTML


共 (0) 个答案