| 发表于:2007-04-01 19:49:30 楼主 |
代码如下: public class lan { public static void main(string[] args) throws unknownhostexception, ioexception { socket s = new socket ( "www.sina.com ",80); system.out.println( "连接成功 "); printstream s1 = new printstream(s.getoutputstream()); system.out.println( "连接成功 "); s1.println( "get /index.html http/1.1 "); s1.println( "accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */* "); s1.println( "accept-language: zh-cn "); s1.println( "accept-encoding: gzip, deflate "); s1.println( "user-agent: mozilla/4.0 (compatible; msie 6.0; windows nt 5.1; sv1; kugoosoft) "); s1.println( "host: localhost:80 "); s1.println( "connection: keep-alive "); s1.println(); s1.flush(); bufferedreader s2 = new bufferedreader(new inputstreamreader(s.getinputstream())); string s3 = null; while((s3=s2.readline())!=null){ system.out.println(s3); } s2.close(); } } 以上程序运行后~会想sina服务器发送相应的请求信息~ 但sina服务器收到我的请求信息后给我的不是它的主页面的html代码~而是一个403 forbiend的错误页面~ 请教下~ 我要是想sina服务器给我正确的主页面的html代码~该怎么做呢???在线等!!!万分感谢! |
|
|
|
|