2016-02-20 69 views
1

你好,我想了解如何從這裏例如http://www.ebay.com/sch/i.html?_sacat=0&_nkw=iphone+5&_frs=1 得到一個具體的價值,並返回值,所以我可以說,將它們與產品名稱一起添加到數據庫中。從html頁面獲得價格

String weburl = "http://www.ebay.com/sch/i.html?_sacat=0&_nkw=iphone+5&_frs=1"; 
      URL oracle = new URL(weburl); 
      BufferedReader in = new BufferedReader(
      new InputStreamReader(oracle.openStream())); 

      String line; 
      while ((line = in.readLine()) != null) 
      { 
       if (line.contains("EUR</b>")) 
       { 
        String command = line.split("EUR</b>").toString(); 
        final String value = command.substring(8); 
        final StringTokenizer s = new StringTokenizer(value, " "); 
        final String DurationString = s.nextToken();     

        System.out.println("Timh: " + DurationString); 
       } 
      } 
      in.close(); 

這不適用於我,直到現在。 我應該如何改變它?

回答