Runnable run=new Runnable() {
        
        @Override
        public void run() {
            // TODO Auto-generated method stub
            userinfos=new ArrayList<UserInfo>();
            
            HttpClient http=new DefaultHttpClient();
            HttpPost post=new HttpPost("http://lolbox.duowan.com/playerList.php");
            List<NameValuePair> parmas=new ArrayList<NameValuePair>();
            parmas.add(new BasicNameValuePair("keyWords", "菜鸟召唤师风哥哥"));
            try {
                post.setEntity(new UrlEncodedFormEntity(parmas,HTTP.UTF_8));
            } catch (UnsupportedEncodingException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }
            try {
        
            HttpResponse response=http.execute(post);
            String result = EntityUtils.toString(response
                    .getEntity());
            //String作为输入源
            Document document=Jsoup.parse(result);
            //File文件作为输入源
            //File input = new File("/tmp/input.html");
            //Document doc = Jsoup.parse(input, "UTF-8", "http://www.example.com/");
            
            //String作为输入源
            //Document doc = Jsoup.connect("http://www.example.com").timeout(60000).get();
            
            Elements elements_url=document.select("td.left");
            Elements elements_texts=document.select("td");
            for(int i=0;i<elements_url.size();i++){
                UserInfo userinfo=new UserInfo();
                Element  element=elements_url.select("a").first();
                Element  element_text=elements_texts.get(i*2+1);
                String text=element_text.text();
                String url=element.attr("href");
                userinfo.setUrl(url);
                userinfo.setArea(text);
                userinfos.add(userinfo);
                Log.d("ssss", url);
                Log.d("ssss", text);
            }    
            } catch (ClientProtocolException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    };
    /*</tr>

    <tr>
        <th width="50%" class="left" scope="col">玩家名字</th>
        <th width="50%" scope="col">服务器</th>
    </tr>

                    <tr>
            <td class="left"><a href="playerDetail.php?serverName=%E7%94%B5%E4%BF%A1%E4%B8%89&playerName=%E8%8F%9C%E9%B8%9F%E5%8F%AC%E5%94%A4%E5%B8%88%E9%A3%8E%E5%93%A5%E5%93%A5">菜鸟召唤师风哥哥</a></td>
            <td >诺克萨斯 电信三</td>
        </tr>
                    <tr>
            <td class="left"><a href="playerDetail.php?serverName=%E7%94%B5%E4%BF%A1%E5%9B%9B&playerName=%E8%8F%9C%E9%B8%9F%E5%8F%AC%E5%94%A4%E5%B8%88%E9%A3%8E%E5%93%A5%E5%93%A5">菜鸟召唤师风哥哥</a></td>
            <td >班德尔城 电信四</td>
        </tr>
            </table>
    <!-- 分页{ -->
  <div class="center" >
    <div class="mod-page">
                </div>*/

 

posted on 2014-05-04 15:33  青年程序猿  阅读(427)  评论(0编辑  收藏  举报