怎样用代码GETwap网站

奋斗-小鸟 2013-04-10 09:20:03
地址是这个:http://wap.cmgame.com/portalone/LoginWapOnlineGame?serviceID=700016595000&contentCode=000038473000&channelID=14017000&SPID=701023&p=iFrs63fjPmkCAPfLvbdt%2FA2t7DXluIobvfPoB3TNioPhgdPHH7URgnWravnjaeDuhsGvxHEnTMlR8l%2By%2FPnJ6ncdN4SJp%2F2RnqGHe6un7%2FOTq4h1a3%2FYBq%2F4cvrwVHF%2FJc392Tml%2BNab%2BDVVAnsf%2Bq6VYQLTdYgZPoUKKxBslQdk8hjqyeof5YRUAx3jB41v27%2F%2BI0Sb%2BiGTIykHt6rvjkM2d6C8DHk5%2BvdSfqEM%2FhWOfND5oZ2hUuAOkyxG1Hbeblw2fRQxxIKKreu1BP1X4wv9VBqd0P%2F1493kN93EfDMqRsa%2BjBcyiWnVc9ZXLa8ItWHNvsE0IZhwzZxFERgHYuoepcrIX0jfVtr4rVHXyI4%3D


我用其他语言可以实现,java怎么写,请大家帮帮忙。刚接触这个
...全文
118 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
奋斗-小鸟 2013-04-10
  • 打赏
  • 举报
回复
我知道是怎么回事了 谢谢您的帮忙。

@Test
	public void httpGet(){
		
		   try {
			     // 创建连接
			   InetAddress addr = InetAddress.getByName("wap.cmgame.com");
			   int port = 80;
			   Socket socket = new Socket(addr, port);

			   // 写入数据
			  BufferedWriter wr = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream(),
			     "UTF-8"));
			  wr.write("GET /portalone/LoginWapOnlineGame?serviceID=700016595000&contentCode=000038473000&channelID=14017000&SPID=701023&p=iFrs63fjPmkCAPfLvbdt%2FA2t7DXluIobvfPoB3TNioPhgdPHH7URgnWravnjaeDuhsGvxHEnTMlR8l%2By%2FPnJ6ncdN4SJp%2F2RnqGHe6un7%2FOTq4h1a3%2FYBq%2F4cvrwVHF%2FJc392Tml%2BNab%2BDVVAnsf%2Bq6VYQLTdYgZPoUKKxBslQdk8hjqyeof5YRUAx3jB41v27%2F%2BI0Sb%2BiGTIykHt6rvjkM2d6C8DHk5%2BvdSfqEM%2FhWOfND5oZ2hUuAOkyxG1Hbeblw2fRQxxIKKreu1BP1X4wv9VBqd0P%2F1493kN93EfDMqRsa%2BjBcyiWnVc9ZXLa8ItWHNvsE0IZhwzZxFERgHYuoepcrIX0jfVtr4rVHXyI4%3D HTTP/1.1\r\n");
			  wr.write("User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"+"\r\n");
			  wr.write("Accept: */*"+"\r\n");
			  wr.write("Host: wap.cmgame.com"+"\r\n");
			  wr.write("Cache-Control: no-cache"+"\r\n");
			  
			  //qqUser.httpClient.Request.UserAgent:= 'WinWAP/3.2 (3.2.1.25; Win32)';
			  wr.write("\r\n");
			  wr.flush();
			  
			  // 创建读取数据的Reader,里面指定了需要的编码类型。
			 BufferedReader rd = new BufferedReader(new InputStreamReader(socket.getInputStream(),
			      "UTF-8"));
			 
			    // 读取每一行的数据.注意大部分端口操作都需要交互数据。
			     String str;
			   while ((str = rd.readLine()) != null) {
			       System.out.println(str);
			     }
			     rd.close();
			      } catch (IOException e) {
			      e.printStackTrace();
			   }


		
	}
	
  • 打赏
  • 举报
回复
public static void main(String[] args) throws Exception {
    	URL url=new URL("http://wap.cmgame.com/portalone/");
    	HttpURLConnection conn = (HttpURLConnection)url.openConnection();
    	InputStream is = conn.getInputStream();
    	BufferedInputStream bis = new BufferedInputStream(is);
    	InputStreamReader isr = new InputStreamReader(bis, "utf-8");
    	BufferedReader br = new BufferedReader(isr);
    	String line=null;
    	while((line=br.readLine())!=null){
    		System.out.println(line);
    	}
    	br.close();
    	isr.close();
    	bis.close();
    	is.close();
    	conn.disconnect();
    }
你哪个连接没有文件
奋斗-小鸟 2013-04-10
  • 打赏
  • 举报
回复
java代码不是不会写 而是java返回的状态是404

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧