台灣最大程式設計社群網站
線上人數
2190
 
會員總數:246497
討論主題:190004
歡迎您免費加入會員
討論區列表 >> VB.NET >> 網頁抓資料-求解
[]  
[我要回覆]
1
回應主題 加入我的關注話題 檢舉此篇討論 將提問者加入個人黑名單
網頁抓資料-求解
價值 : 10 QP  點閱數:381 回應數:1
樓主

mars
門外漢
0 2
18 1
發送站內信



Imports System.Web
Imports System.Net.Sockets 'HttpWebRequest、HttpWebResponse類別
Imports System.Net
Imports System.IO 'StreamReader類別


System.Net.ServicePointManager.DefaultConnectionLimit = 50
Dim request As HttpWebRequest
request = WebRequest.Create("http://www.cmegroup.com/CmeWS/mvc/Settlements/Futures/Settlements/58/FUT?strategy=DEFAULT&tradeDate=05/18/2021")
Dim mResponse As HttpWebResponse = request.GetResponse() <===到這就作業逾時

Dim sr As New StreamReader(mResponse.GetResponseStream, System.Text.Encoding.GetEncoding("UTF-8"))
Dim strContent = sr.ReadToEnd()
Dim strContent = sr.ReadToEnd()
sr.Close()
request = Nothing
mResponse = Nothing
MsgBox(strContent)



有試著加這些東西>但沒用一樣逾時
request.Method = "GET"
request.Host = "www.cmegroup.com"
request.KeepAlive = True
request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9"
request.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36"

request.Headers.Set("Accept-Encoding", "gzip, deflate, br")
request.Headers.Set("Accept-Language", "zh-TW,zh;q=0.9,en-US;q=0.8,en;q=0.7")
request.Headers.Set("Cache-Control", "max-age=0")
request.Headers.Set("sec-ch-ua", " ""Not A;Brand"";v=""99"", ""Chromium"";v=""90"", ""Google Chrome"";v=""90""")
request.Headers.Set("sec-ch-ua-mobile", "?0")
request.Headers.Set("Sec-Fetch-Dest", "document")
request.Headers.Set("Sec-Fetch-Mode", "navigate")
request.Headers.Set("Sec-Fetch-Site", "none")
request.Headers.Set("Sec-Fetch-User", "?1")
request.Headers.Set("Upgrade-Insecure-Requests", "1")
request.Timeout = 100000






搜尋相關Tags的文章: [ HttpWebRequest ] ,
本篇文章發表於2021-05-19 11:26
1樓
作者回應

mars
檢舉此回應
已解 !!!
新增request.Headers.Set("X-Requested-With", "XMLHttpRequest")
本篇文章回覆於2021-05-19 13:18
== 簽名檔 ==
--未登入的會員無法查看對方簽名檔--
   
1

回覆
如要回應,請先登入.