bl双性强迫侵犯h_国产在线观看人成激情视频_蜜芽188_被诱拐的少孩全彩啪啪漫画

使用harexporttrigger導出瀏覽器HAR數(shù)據

1,環(huán)境

1)Firefox 45.0
下載地址:http://ftp.mozilla.org/pub/firefox/releases

創(chuàng)新互聯(lián)是一家專業(yè)提供東坡企業(yè)網站建設,專注與成都做網站、網站建設、HTML5建站、小程序制作等業(yè)務。10年已為東坡眾多企業(yè)、政府機構等服務。創(chuàng)新互聯(lián)專業(yè)網絡公司優(yōu)惠進行中。

2)harexporttrigger-0.5.0-beta.10.xpi
下載地址:http://www.softwareishard.com/blog/har-export-trigger/
https://github.com/firebug/har-export-trigger/releases

3)selenium-java-2.53.1.jar

<dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>2.53.1</version> 
</dependency>

2,實現(xiàn)代碼


public static String BROWSER_PATH = "C:\\Program Files\\Mozilla Firefox\\firefox.exe";

public static String HAR_EXPORTTRIGGER_PATH = "D:\\firefoxxpi\\harexporttrigger-0.5.0-beta.10.xpi" ;

private final static String HARDIR = "d:\\firefoxharlog";

public void init() {
        System.setProperty("webdriver.firefox.bin", BROWSER_PATH);  
}

private FirefoxProfile  buildNetmonitorProfile() throws IOException {
        FirefoxProfile profile = new FirefoxProfile();  

        // Load extensions         
        File harExport = new File(HAR_EXPORTTRIGGER_PATH); //adjust path as needed
        profile.addExtension(harExport);

        // Enable the automation without having a new HAR file created for every loaded page.
        profile.setPreference("extensions.netmonitor.har.enableAutomation", true);
        // Set to a token that is consequently passed into all HAR API calls to verify the user.
        profile.setPreference("extensions.netmonitor.har.contentAPIToken", "test");
        // Set if you want to have the HAR object available without the developer toolbox being open.
        profile.setPreference("extensions.netmonitor.har.autoConnect", true);

        // Enable netmonitor
        profile.setPreference("devtools.netmonitor.enabled", true);
        // If set to true the final HAR file is zipped. This might represents great disk-space optimization especially if HTTP response bodies are included.
        profile.setPreference("devtools.netmonitor.har.compress", false);
        // Default name of the target HAR file. The default file name supports formatters
        profile.setPreference("devtools.netmonitor.har.defaultFileName", "Autoexport_%y%m%d_%H%M%S");
        // Default log directory for generate HAR files. If empty all automatically generated HAR files are stored in <FF-profile>/har/logs
        profile.setPreference("devtools.netmonitor.har.defaultLogDir", HARDIR);
        // If true, a new HAR file is created for every loaded page automatically.
        profile.setPreference("devtools.netmonitor.har.enableAutoExportToFile", true);
        // The result HAR file is created even if there are no HTTP requests.
        profile.setPreference("devtools.netmonitor.har.forceExport", true);   
        // If set to true, HTTP response bodies are also included in the HAR file (can produce significantly bigger amount of data).
        profile.setPreference("devtools.netmonitor.har.includeResponseBodies", false);
        // If set to true the export format is HARP (support for JSONP syntax that is easily transferable cross domains)
        profile.setPreference("devtools.netmonitor.har.jsonp", false);
        // Default name of JSONP callback (used for HARP format)
        profile.setPreference("devtools.netmonitor.har.jsonpCallback", false);
        // Amount of time [ms] the auto-exporter should wait after the last finished request before exporting the HAR file.
        profile.setPreference("devtools.netmonitor.har.pageLoadedTimeout", "2500");

        //to prevent Firefox >= 65 from automatically updating whilst under automation.
        //profile.setPreference("app.update.disabledForTesting", "true");
        //profile.setPreference("devtools.console.stdout.content", "true");

        return profile ;
}

public void resovle(String url) throws Exception {
        WebDriver driver = null;
        try {
            FirefoxProfile profile = buildNetmonitorProfile() ;

            driver = new FirefoxDriver(profile);

            //存放Har數(shù)據的路徑(目錄)
            final File harDir = new File(HARDIR);
            //獲取當前的文件數(shù)[用于下面判斷文件是否生成]
            final int numFiles = harDir.listFiles().length;

            //訪問資源
            driver.get(url);

            // 等待創(chuàng)建好HAR文件
            for (int c=0; c<30; c++) {
                if (harDir.listFiles().length > numFiles) {
                    break;
                }
                Thread.sleep(1000L);
            }
        }
        catch (Exception exc) {
            System.err.println("error --> " + exc);
        }
        if (driver != null) {
            driver.quit();
        }
    }

標題名稱:使用harexporttrigger導出瀏覽器HAR數(shù)據
當前地址:http://vcdvsql.cn/article16/pocdgg.html

成都網站建設公司_創(chuàng)新互聯(lián),為您提供企業(yè)網站制作外貿建站網站排名網站收錄自適應網站

廣告

聲明:本網站發(fā)布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)

成都定制網站建設