綁定帳號登入

Android 台灣中文網

打印 上一主題 下一主題

[求助] 用Jsoup去剖析網頁

[複製連結] 查看: 1481|回覆: 0|好評: 0
跳轉到指定樓層
樓主
陳萱翰 | 收聽TA | 只看該作者 回帖獎勵 |倒序瀏覽 |閱讀模式
發表於 2014-4-23 20:12
1碎鑽
我剖析這個網頁~~這個網頁~~
出現了錯誤

我用DEBUG模式看,沒有發現任何錯誤,但卻發現在這一段發現沒有辦法剖析html資訊
Document doc;                          
doc = Jsoup.parse(url, 3000);
Html資訊無法被分析出來,後面的程式所以無法的到資料
想請教各位高手有無碰過類似的情況
(目前我還未找到相關的解決方法)
謝謝
private OnClickListener btsearchitemListener = new OnClickListener()
    {
      public void onClick(View v)
      {
        // TODO Auto-generated method stub  
        
        Handler handler = new Handler();
        handler.post(new Runnable() {
        //User_menu.this.runOnUiThread(new Runnable(){
          public void run() {
            // TODO Auto-generated method stub                     
            editText1.setHint("");
            
            URL url ;
              String Http_keyWord = "http://tw.search.bid.yahoo.com/search/auction/product?p=%s", Http, Keyword;
            //String Http_keyWord = "https://tw.search.yahoo.com/search?p=u+zj6&fr=yfp&ei=utf-8&v=0", Http, Keyword;  

            
            AllDatainfos = new ArrayList<HashMap<String, Object>>();
            
            Keyword = editText1.getText().toString().trim();
            tvspottempp = (TextView)findViewById(R.id.tvspottempp);
            tvspottempp.setText("Keyword:"+Keyword);                        
            
            Http = String.format(Http_keyWord, UTF8EnCode(Keyword));
            tvspottempp1 = (TextView)findViewById(R.id.tvspottempp1);
            tvspottempp1.setText("Http:"+Http);
            
              try
                {
                url = new URL(Http.toString());
                tvspottempp2 = (TextView)findViewById(R.id.tvspottempp2);
                tvspottempp2.setText("url:"+url);
               
                Document doc;         
                doc = Jsoup.parse(url, 3000);
                tvspottempp2 = (TextView)findViewById(R.id.tvspottempp3);
                tvspottempp2.setText("doc:"+doc);
               
                Elements paramDocuments = doc.select("#srp_result_list, #srp_gaze_list").select(".grid-type.yui3-g > *");
                Iterator localIterator = paramDocuments.select("#srp_result_list, #srp_gaze_list").select(".grid-type.yui3-g > *").iterator();
               
                  while (true)
                  {
                    if (!localIterator.hasNext())
                      return;
                    Element localElement1 = (Element)localIterator.next();
                    try
                    {
                      SearchResultItem localSearchResultItem = new SearchResultItem();
                      Element localElement2 = localElement1.select(".wrap").first();
                      parsePhoto(localSearchResultItem, localElement2);
                      parsePrice(localSearchResultItem, localElement2);
                      parseTitle(localSearchResultItem, localElement2);               
                    }
                    catch (Exception localException2)
                    {
                      localException2.printStackTrace();
                    }
                  }
                }catch (MalformedURLException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
              }
                catch (Exception localException1)
                {
                  localException1.printStackTrace();
                }            
             }
             });
           }  
          };

「用Android 就來APK.TW」,快來加入粉絲吧!
Android 台灣中文網(APK.TW)
收藏收藏 分享分享 分享專題
用Android 就來Android 台灣中文網(https://apk.tw)
回覆

使用道具 舉報

您需要登錄後才可以回帖 登錄 | 註冊

本版積分規則