本文整理匯總了Java中com.gargoylesoftware.htmlunit.BrowserVersion.FIREFOX_24屬性的典型用法代碼示例。如果您正苦於以下問題:Java BrowserVersion.FIREFOX_24屬性的具體用法?Java BrowserVersion.FIREFOX_24怎麽用?Java BrowserVersion.FIREFOX_24使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類com.gargoylesoftware.htmlunit.BrowserVersion
的用法示例。
在下文中一共展示了BrowserVersion.FIREFOX_24屬性的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setupClient
private WebClient setupClient(final String username, final String password) {
final WebClient client = new WebClient(BrowserVersion.FIREFOX_24);
final WebClientOptions options = client.getOptions();
DefaultCredentialsProvider credentials = new DefaultCredentialsProvider();
credentials.addCredentials(username, password);
client.setCredentialsProvider(credentials);
options.setRedirectEnabled(true);
options.setThrowExceptionOnFailingStatusCode(true);
client.addWebWindowListener(new ValidateOnContentChange());
client.getCookieManager().setCookiesEnabled(false);
// Try to log only "interesting" things:
// Don't log errors we can't fix due to browser bugs etc.
client.setIncorrectnessListener(new SuppressingIncorrectnessListener());
return client;
}
示例2: getAnimeImageUrl
/**
* Returns the Url of image for the animeId provided. The file type extension is not included.
* @param animeId
* @return null if not found
* @throws FailingHttpStatusCodeException
* @throws MalformedURLException
* @throws IOException
*/
public static String getAnimeImageUrl(int animeId) throws FailingHttpStatusCodeException, MalformedURLException, IOException{
String theReturn = null;
final WebClient webClient = new WebClient(BrowserVersion.FIREFOX_24);
webClient.getOptions().setThrowExceptionOnScriptError(false);//Will give alot of errors
new IgnoreRandomJScripts(webClient);
java.util.logging.Logger.getLogger("com.gargoylesoftware.htmlunit").setLevel(java.util.logging.Level.SEVERE);//to ignore those errors
try{
Page page = webClient.getPage("http://myanimelist.net/anime.php?id="+animeId);
if(page.isHtmlPage()){
Pattern p = Pattern.compile("http://cdn.myanimelist.net/images/anime/([0-9]+)/([0-9]+).jpg");
Matcher m = p.matcher(page.getWebResponse().getContentAsString());
if(m.find()){
if(m.groupCount() == 2){
theReturn = "http://cdn.myanimelist.net/images/anime/"+m.group(1)+"/"+m.group(2);
}
}
}
}
catch(com.gargoylesoftware.htmlunit.ScriptException e){}
webClient.closeAllWindows();
java.util.logging.Logger.getLogger("com.gargoylesoftware.htmlunit").setLevel(java.util.logging.Level.ALL);
return theReturn;
}
示例3: downloadImage
/**
* Downloads and saves Jpeg from url and stores as file
* @param url
* @param saveLoc
* @return true on success
* @throws FailingHttpStatusCodeException
* @throws MalformedURLException
* @throws IOException
*/
public static boolean downloadImage(String url, String saveLoc) throws FailingHttpStatusCodeException, MalformedURLException, IOException{
if(url != null && saveLoc != null){
if(!url.isEmpty() && !saveLoc.isEmpty()){
final WebClient webClient = new WebClient(BrowserVersion.FIREFOX_24);
Page page = webClient.getPage(url);
webClient.closeAllWindows();
if(page.getWebResponse().getContentType().equals("image/jpeg")){//grabbed the xml file
InputStream in = page.getWebResponse().getContentAsStream();
OutputStream out; out = new FileOutputStream(new File(System.getProperty("user.dir") + saveLoc));
IOUtils.copy(in,out);
return true;
}
}
}
return false;
}
示例4: getAnimeList
/**
* Retrieves the anime history for inputted user
* @param username
* @param rssType rw
* @return XML as String
* @throws FailingHttpStatusCodeException
* @throws MalformedURLException
* @throws IOException
*/
public static String getAnimeList(String username, String rssType) throws FailingHttpStatusCodeException, MalformedURLException, IOException{
final WebClient webClient = new WebClient(BrowserVersion.FIREFOX_24);
Page page = webClient.getPage("http://myanimelist.net/rss.php?type="+rssType+"&u="+username);
//System.out.println(page.getWebResponse().getContentAsString());
String content = page.getWebResponse().getContentAsString();
webClient.closeAllWindows();
if(content.startsWith("<?xml") && content.length() > 350){//grabbed the xml file
return content;
}
return null;
}
示例5: commonHtmlUnitDriverStepHelper
@Bean
@Scope(value = "prototype")
public CommonHtmlUnitDriverStepHelper commonHtmlUnitDriverStepHelper() throws MalformedURLException {
return new CommonHtmlUnitDriverStepHelper(new HtmlUnitDriver(BrowserVersion.FIREFOX_24), webappUrl(), populatePageUrl());
}
示例6: htmlUnitDriver
@SuppressWarnings("unused")
private static WebDriver htmlUnitDriver() {
HtmlUnitDriver driver = new HtmlUnitDriver(BrowserVersion.FIREFOX_24);
driver.setJavascriptEnabled(true);
return driver;
}