[請益] 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