[请益] PTT爬虫

楼主: daviden (daviden)   2015-06-23 03:21:12
小弟最近在写爬虫
用的语言是Visual Basic。目前可以用httpWebRequest下载到一般网页原始码
但是对于有凭证要求的网页,例如PTT八卦板网页版,会要求使用者点选"已满18岁",
就不知道要如何通过。
小弟的问题是,VB要怎么写WebRequest的POST?
参考过一些网友的写法,以及MSDN,目前有的code
Dim Req As Net.WebRequest
Dim postData As String =
"referer:https://www.ptt.cc/ask/over18?from=%2Fbbs%2FGossiping%2Findex.html"
Dim byteArray As Byte() = Encoding.UTF8.GetBytes(postData)
Req = Net.WebRequest.Create("https://www.ptt.cc/ask/over18")
Req.Method = "POST"
Req.ContentType = "application/x-www-form-urlencoded"
Req.ContentLength = byteArray.Length
Dim dataStream As Stream = Req.GetRequestStream()
dataStream.Write(byteArray, 0, byteArray.Length)
dataStream.Close()
这个POST没有效果......
希望大大不吝指教!
感谢~~

Links booklink

Contact Us: admin [ a t ] ucptt.com