我试图发送一个请求,返回一个页面源文件,我用抓包工具提取了发送时的发送请求,但用vb编写的时候出现以下错误:
实时错误‘10037’:
The operation is completed.No blocking operation is in progress
我要返回的是www.51cha.com这个页面,源程序如下:
Private Sub Command1_Click()
Dim str As String
str = "GET / HTTP/1.1" & Chr(13) & Chr(10)
str = str & "Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-powerpoint, application/msword, application/x-shockwave-flash, */*" & Chr(13) & Chr(10)
str = str & "Accept-Language: zh-cn" & Chr(13) & Chr(10)
str = str & "Accept-Encoding: gzip, deflate" & Chr(13) & Chr(10)
str = str & "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)" & Chr(13) & Chr(10)
str = str & "Host: www.51cha.com" & Chr(13) & Chr(10)
str = str & "Connection: Keep-Alive" & Chr(13) & Chr(10) & Chr(13) & Chr(10) & Chr(13) & Chr(10)
winsock.Connect
winsock.Listen
winsock.SendData str
winsock.GetData Text2.Text
winsock.Close
End Sub
其中,抓包得到的请求为:
GET / HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-powerpoint, application/msword, application/x-shockwave-flash, */*
Accept-Language: zh-cn
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)
Host: www.51cha.com
Connection: Keep-Alive请问是如何出错的?
实时错误‘10037’:
The operation is completed.No blocking operation is in progress
我要返回的是www.51cha.com这个页面,源程序如下:
Private Sub Command1_Click()
Dim str As String
str = "GET / HTTP/1.1" & Chr(13) & Chr(10)
str = str & "Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-powerpoint, application/msword, application/x-shockwave-flash, */*" & Chr(13) & Chr(10)
str = str & "Accept-Language: zh-cn" & Chr(13) & Chr(10)
str = str & "Accept-Encoding: gzip, deflate" & Chr(13) & Chr(10)
str = str & "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)" & Chr(13) & Chr(10)
str = str & "Host: www.51cha.com" & Chr(13) & Chr(10)
str = str & "Connection: Keep-Alive" & Chr(13) & Chr(10) & Chr(13) & Chr(10) & Chr(13) & Chr(10)
winsock.Connect
winsock.Listen
winsock.SendData str
winsock.GetData Text2.Text
winsock.Close
End Sub
其中,抓包得到的请求为:
GET / HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-powerpoint, application/msword, application/x-shockwave-flash, */*
Accept-Language: zh-cn
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)
Host: www.51cha.com
Connection: Keep-Alive请问是如何出错的?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货