本文整理汇总了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;
}