gpt4 book ai didi

lotus-notes - 从网页获取字段值 - lotusscript

转载 作者:行者123 更新时间:2023-12-02 22:27:44 24 4
gpt4 key购买 nike

我需要使用 lotusscript 从网页中读取字段值。本质上,我计划编写一个代理来访问特定的 URL,从页面获取一个值,然后将此值用于它将用户发送到的 url。

谁能指点一下?

一个

最佳答案

2019 年 12 月更新:从 Notes 10(2018 年发布)开始,有一个 NotesHTTPRequest 类与我的代码做的事情完全相同。 em>

我一直这样做,一点也不难(在 Windows 上)。我创建了一个类来执行此操作,因此很容易实现。

你可以这样调用它:

Dim internet As New RemoteHTML()
Dim html As String
html = internet.GetHTTP("http://www.texasswede.com/mypage.html")

就是这样,现在您只需从 html 字符串中提取所需的任何信息即可。

这是类:

Option Public
Option Declare

Class RemoteHTML
Private httpObject As Variant
Public httpStatus As Integer

Public Sub New()
Set httpObject = CreateObject("MSXML2.ServerXMLHTTP")
End Sub

Public Function GetHTTP(httpURL As String) As String
Dim retries As Integer
retries = 0
Do
If retries>1 Then
Sleep 1 ' After the two first calls, introduce a 1 second delay betwen each additional call
End If
retries = retries + 1
Call httpObject.open("GET", httpURL, False)
Call httpObject.send()
httpStatus = httpObject.Status
If retries >= 10 Then
httpStatus = 0 ' Timeout
End If
Loop Until httpStatus = 200 Or httpStatus > 500 Or httpStatus = 404 Or httpStatus = 0
If httpStatus = 200 Then
GetHTTP = Left$(httpObject.responseText,16000)
Else
GetHTTP = ""
End If
End Function


Public Function GetFile(httpURL As String, filename As String) As Boolean
Dim session As New NotesSession
Dim retries As Integer
Dim stream As NotesStream
Dim flag As Boolean
Dim responsebody As variant
Dim cnt As Long
Dim buffer As String
Dim tmp As Byte

Set stream = session.CreateStream
retries = 0
Do
If retries>1 Then
Sleep 1 ' After the two first calls, introduce a 1 second delay betwen each additional call
End If
retries = retries + 1
Call httpObject.open("GET", httpURL, False)
Call httpObject.send()
httpStatus = httpObject.Status
If retries >= 10 Then
httpStatus = 0 ' Timeout
End If
Loop Until httpStatus = 200 Or httpStatus > 500 Or httpStatus = 404 Or httpStatus = 0
If httpStatus = 200 Then
flag = stream.Open(filename, "binary")
If flag = False Then
MsgBox "Failed to create " & filename & "..."
GetFile = False
Exit function
End If
responsebody = httpObject.ResponseBody
ForAll r in responsebody
tmp = r
Call Stream.Write(Chr$(CInt(tmp)))
cnt = cnt + 1
End ForAll
MsgBox cnt
GetFile = True
Else
GetFile = False
End If

End Function

Private Function getString(ByVal StringBin As string)
Dim intCount As Long
getString =""
For intCount = 1 To LenB(StringBin)
getString = getString & Chr( Asc(MidB(StringBin, intCount, 1)) )
Next
End Function

End Class

关于lotus-notes - 从网页获取字段值 - lotusscript,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12719192/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com