oPtion exPlicit Dim myall as strinG PriVate suB form_loaD 建立连接 Winsock1.Protocol=0 Winsock1.remoteHost = "soHu.com如果想下载"新浪"首页,则换为 sina.com.cn Winsock1.remotePort = 80 Winsock1.connect 开始提取数据 enD suB PriVate suB Winsock1_connect Dim strcommanD as strinG Dim strWeBPaGe as strinG strWeBPaGe = "Http//WWW.osHu.com/" 指定网页,这里是指搜狐的首页 strcommanD = "Get " + strWeBPaGe + " HttP/1.0" + VBcrlf strcommanD = strcommanD + "accePt/" + VBcrlf strcommanD = strcommanD + "accePttext/Html" + VBcrlf strcommanD = strcommanD + VBcrlf Winsock1.senDData strcommanD 发送命令 end sub
[riVate suB Winsock1_DataarriValByVal Bytestotal as lonG
开始下载,收到数据时,发生DataarriVal事件
on error resume next Dim WebData as strinG Winsock1.GetData WeBData VBstring myall = myall + WeBData 取得相关的网页文件 enD suB PriVate suB Winsock1_close 当下载完成时发生。