最后更新时间:2005年9月7日
更新了HttpDriver类

这个经过测试,使用上比较稳定,因为考虑到统一的错误处理,类里面没有catch任何错误,所有网络错误都在使用的时候捕获,以便决定重试或终止。支持get和post,支持自定义编码,支持cookie,但不支持上传文件。

用来获取网页的类Imports System.Net
用来获取网页的类
Imports System.IO
用来获取网页的类



如果需要支持cookie,并支持refer,可以通过下面这个类来使用上面的httpdriver。

用来获取网页的类'该类用于访问含有cookie的页面
用来获取网页的类
Imports System.IO
用来获取网页的类



轻量的get网页的函数


Get方法:

用来获取网页的类Dim ua as New UserAgent
用来获取网页的类
Dim content as String
用来获取网页的类
Dim url as String
用来获取网页的类url 
= "www.sina.com.cn"
用来获取网页的类
content = ua.GetPage(url)
   url = "sohu.com"
用来获取网页的类content = ua.GetPage(url)
用来获取网页的类


Post方法(页面和参数名字都是示例)。UserAgent的好处是可以透明的保存cookie,用以下的方法就可以实现登录后保存登录信息了。

用来获取网页的类Dim ua as New UserAgent
用来获取网页的类
Dim content as String
用来获取网页的类
Dim url as String
用来获取网页的类
Dim ht as New HashTable
用来获取网页的类
用来获取网页的类url 
= "mail.sina.com.cn"
用来获取网页的类
ht.Add("username""用户名")
用来获取网页的类ht.Add(
"password""密码")
用来获取网页的类content 
= ua.GetPage(url, ht)
   url = "mail.sina.com.cn/default.htm"
   content = ua.GetPage(url)


欢迎大家批评、补充、指正。用来获取网页的类

相关文章:

  • 2021-08-14
  • 2022-02-08
  • 2021-11-20
  • 2021-11-18
  • 2021-12-05
  • 2021-11-07
  • 2021-08-11
  • 2021-12-03
猜你喜欢
  • 2022-12-23
  • 2022-03-07
  • 2021-07-21
  • 2022-12-23
相关资源
相似解决方案