標題:
[發問]
請問哪邊寫錯有問題無法登入網頁
[打印本頁]
作者:
BANK870
時間:
2023-12-3 19:51
標題:
請問哪邊寫錯有問題無法登入網頁
請問哪邊寫錯有問題無法登入網頁
Sub 巨集2()
'
' 巨集2 巨集
'
Dim Http As Object
Dim Username As String, Password As String
Dim Url As String, Data As String
' 設定帳號和密碼
Username = "***@gmail.com"
Password = "***"
' 設定目標網頁的URL和POST資料
Url = "https://thefew.tw/login"
Data = "username=" & Username & "&password=" & Password
' 建立XMLHttpRequest物件
Set Http = CreateObject("MSXML2.XMLHTTP")
' 設定請求參數
Http.Open "POST", Url, False
Http.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
' 傳送請求
Http.send Data
' 檢查回應狀態碼,如果是200表示登入成功
If Http.Status = 200 Then
' 登入成功後,您可以使用XMLHttpRequest物件下載所需的資料
' ...
Else
MsgBox "登入失敗"
End If
' 設定帳號和密碼
With ActiveSheet.QueryTables.Add(Connection:="URL;https://thefew.tw/cb", _
Destination:=Range("$A$1"))
' .CommandType = 0
.Name = "cb"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlAllTables
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
End Function
歡迎光臨 麻辣家族討論版版 (http://forum.twbts.com/)