2014-09-02 2 views
1

YouTube 링크가 채널에 게시되면 내 IRC 봇이 동영상 통계를 보냅니다. 하지만 엄청난 수의 경고를 얻을 수 및 그들이 나를 성가 시게하고 단지 내 콘솔을 혼란 :콘솔에서 경고를 끄려하지만 실패 함

Sep 01, 2014 6:09:29 PM com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error 
WARNUNG: CSS error: 'https://s.ytimg.com/yts/cssbin/www-core-vfl0pJopz.css' [1:41191] Fehler in Style-Regel. (Ungültiger Token "*". Erwartet wurde einer von: <EOF>, <S>, <IDENT>, "}", ";".) 
Sep 01, 2014 6:09:29 PM com.gargoylesoftware.htmlunit.DefaultCssErrorHandler warning 
WARNUNG: CSS warning: 'https://s.ytimg.com/yts/cssbin/www-core-vfl0pJopz.css' [1:41191] Ignoriere die folgenden Deklarationen in dieser Regel. 

내가 그들을 해제하고 싶습니다, 그리고 내 주요 방법이 코드를 추가하는 시도 :

java.util.logging.Logger.getLogger("com.gargoylesoftware").setLevel(Level.OFF); 

하지만 아무 소용이 없습니다.

String[] args = Utilities.toArgs(event.getMessage()); //this is the message sent, split by a space 
     String link = null; 
     boolean shortLink = false; 
     WebDriver driver = new HtmlUnitDriver(); 
     String title = "No value"; 
     String duration = "No value"; 
     String views = "No value"; 
     String likes = "No value"; 
     String dislikes = "No value"; 
     String date = "No value"; 
     String uploader = "No value"; 

     for(String s : args) 
     { 
      if(s.contains("www.youtube.com/watch")) 
      { 
       if(s.contains("v=")) 
        link = "http://www.youtube.com/watch?v=" + s.split("v=")[1].substring(0, 11) + "/"; 
       else 
       { 
        Utilities.chanMsg(event, "Couldn't find video id!"); //just sending a message to the channel 
        break; 
       } 
      } 
      else if(s.contains("http://youtu.be/")) 
      { 
       link = s; 
       shortLink = true; 
       break; 
      } 
     } 

     if(shortLink) 
     { 
      String videoId = link.split("/")[3]; 

      link = "www.youtube.com/watch?v=" + videoId; 
     } 

     //if someone posts the link without a space between the link and the word before it 
     if(!link.startsWith("w")) 
      link = link.split(":")[1].substring(2); 

     //check that the link is really the link needed (main use is when someone posts a word directly after the link without a space inbetween) 
     if(link.length() != 35) 
     { 
      StringBuilder builder = new StringBuilder(); 
      builder.append(link); 
      builder.delete(35, link.length()); 
      link = builder.toString(); 
     } 

     //make sure that the links starts with "http://" 
     if(!link.startsWith("http://")) 
      link = "http://" + link; 

     driver.get(link); 

     try 
     { 
      title = driver.findElement(By.xpath("//meta[@itemprop='name']")).getAttribute("content"); 
     } 
     catch(NoSuchElementException e){} 

     try 
     { 
      duration = resolveDuration(driver); 
     } 
     catch(NoSuchElementException e){} 

     try 
     { 
      views = driver.findElement(By.xpath("//div[@class='watch-view-count']")).getText(); 
     } 
     catch(NoSuchElementException e) 
     { 
      views = driver.findElement(By.xpath("//span[@class='watch-view-count yt-uix-hovercard-target']")).getText().split("Views")[0]; 
     } 

     try 
     { 
      likes = driver.findElement(By.xpath("//button[@id='watch-like']/span[@class='yt-uix-button-content']")).getText(); 
     } 
     catch(NoSuchElementException e){} 

     try 
     { 
      dislikes = driver.findElement(By.xpath("//button[@id='watch-dislike']/span[@class='yt-uix-button-content']")).getText(); 
     } 
     catch(NoSuchElementException e){} 

     try 
     { 
      date = driver.findElement(By.xpath("//p[@id='watch-uploader-info']/strong")).getText().split("on")[1]; 
     } 
     catch(NoSuchElementException e){} 

     try 
     { 
      uploader = driver.findElement(By.xpath("//div[@class='yt-user-info']/a")).getText(); 
     } 
     catch(NoSuchElementException e){} 

     driver.close(); 

그래서 어떻게 콘솔에 보낸 경고를 억제 할 수있을 것입니다 :이 코드를 사용하여 결과를 얻을 Selenium을 사용하고? 이러한 능력은 webdriver.log.driver처럼 될 것입니다 파이어 폭스에 대한 브라우저 specific.Say 은 비록

+0

waring과 경고 사이에 다른 철자가 있습니다. – StackFlowed

+2

@Aeshang "Warnung"은 "경고"의 독일어입니다. – bl4ckscor3

답변

관련 문제