import java.net.*; import java.io.*; public class t { public t() { } public static void main(String[] args) { try { String key = "java"; //查询关键字 key = URLEncoder.encode(key, "gb2312"); URL u = new URL("http://www.baidu.com.cn/s?wd=" + key + "&cl=3"); URLConnection conn = u.openConnection(); BufferedReader reader = new BufferedReader(new InputStreamReader( conn.getInputStream(), "gb2312")); String str = reader.readLine(); while (str != null) { System.out.println(str); str = reader.readLine(); } reader.close(); } catch (Exception ex) { ex.printStackTrace(); } } }
调用百度搜索接口查询
最新推荐文章于 2024-09-14 07:24:55 发布