需要输入用户名密码才可以浏览的网页如何获取源文件?

herodraw 2005-07-06 04:25:57
不需要输入用户名密码的我知道了

对于需要输入用户名密码才可以浏览的网页如何获取源文件?(例如用户名是aaa密码是bbb)
在HttpWebRequest.Create("")的时候输入么?如何输入!


或者请csdn小助手的作者帮我看看,你的源码我看了 可是还不是很明白!谢谢
...全文
332 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
herodraw 2005-08-08
  • 打赏
  • 举报
回复
Function posttofile(ByVal HttpUrl As String, ByVal poststr As String)
Dim Cookies As Net.CookieContainer = Nothing
Try
Dim code As String = "GB18030"
Dim Url As New System.Uri(HttpUrl & "?" & poststr)

Dim req As HttpWebRequest = WebRequest.Create(Url)
Dim SomeByte() As Byte = System.Text.Encoding.ASCII.GetBytes(poststr)
req.AllowAutoRedirect = True
req.Method = "POST"
req.ContentType = "application/x-www-form-urlencoded"
req.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; Q312461; .NET CLR 1.0.3705)"
If Not (poststr Is Nothing) Then
req.ContentLength = SomeByte.Length
Else
req.ContentLength = 0
End If
If Not (Cookies Is Nothing) Then
req.CookieContainer = Cookies
Else
req.CookieContainer = New Net.CookieContainer
Cookies = req.CookieContainer
End If
req.GetRequestStream.Write(SomeByte, 0, SomeByte.Length)
Dim res As HttpWebResponse = req.GetResponse
Dim ReadStream As StreamReader = New StreamReader(res.GetResponseStream, System.Text.Encoding.GetEncoding(code))
Return ReadStream.ReadToEnd
Catch
End Try
End Function

然后posttofile("http://www.xxx.net/userlogin.asp", "guid=aaaa&passwd=bbbb")
没有后面的“&passwd=bbbb”的我试过了可以用
Ordin 2005-07-31
  • 打赏
  • 举报
回复
chenhaohf 2005-07-30
  • 打赏
  • 举报
回复
Dim myRequest As HttpWebRequest
myRequest = HttpWebRequest.Create(url)
Dim response As HttpWebResponse
Dim postData As String
postData = "uid=uid&pwd=pwd"
myRequest.ContentType = "application/x-www-form-urlencoded"
myRequest.ContentLength = postData.Length
myRequest.Method = "POST"
myRequest.AllowAutoRedirect = False
Dim requestStream As Stream = myRequest.GetRequestStream()
Dim postBytes As Byte() = Encoding.ASCII.GetBytes(postData)
requestStream.Write(postBytes, 0, postBytes.Length)
requestStream.Close()
response = myRequest.GetResponse()
Dim Rd As New StreamReader(response.GetResponseStream(), GB)
Dim HPage As String()
HPage = Split(Rd.ReadToEnd, vbCrLf)
不跳转的页可以,跳转的可能要修改myRequest.AllowAutoRedirect 没试过
wuhong303 2005-07-30
  • 打赏
  • 举报
回复
那用cookie又怎么登陆呢
landlordh 2005-07-09
  • 打赏
  • 举报
回复
不知你是会员登陆(一般都是用cookie)
还是域登陆(没有试过)
herodraw 2005-07-08
  • 打赏
  • 举报
回复
唉...都放了两天了
都没人给点建议?
herodraw 2005-07-07
  • 打赏
  • 举报
回复
ding
terryxin 2005-07-06
  • 打赏
  • 举报
回复
帮你顶下
herodraw 2005-07-06
  • 打赏
  • 举报
回复
大家帮我看看呀
谢谢啦
我真的招了很多地方了
还没有招到合适的方法
herodraw 2005-07-06
  • 打赏
  • 举报
回复

16,554

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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