我知道这个话题已经讨论过很多次了,但我需要了解如何以正确的方式编写代码。
我在协议版本 HTTP 1.1 中多次使用相同的 HttpWebRequest(到相同的 url)。
Method = "POST"
KeepAlive = True
Run Code Online (Sandbox Code Playgroud)
但每次我需要发送不同的请求,并得到不同的响应。
(注意。下一个代码不正确并引发异常)
Private Sub SendHttpWebReq()
Dim httpWebReq = CType(Net.WebRequest.Create("http://www.contoso.com/"), Net.HttpWebRequest)
httpWebReq.Method = "POST"
httpWebReq.KeepAlive = True
httpWebReq.ContentType = "application/x-www-form-urlencoded"
Dim myRequestString As New List(Of String) From {"abc", "def"}
Dim ContentList As New List(Of String)
For a = 0 To 1
Dim inputData As String = MyRequestString(a)
Dim postData As String = "firstone" + ChrW(61) + inputData
Dim encoding As New System.Text.ASCIIEncoding()
Dim byteData As Byte() = encoding.GetBytes(postData) …Run Code Online (Sandbox Code Playgroud) 我正在尝试将 HtmlAgilityPack 与 Selenium 一起使用。我想做一些测试,但不知道如何从 Selenium Driver.PageSource String 加载 HtmlDocument。有什么帮助吗?(c# 或 vb.net)
这里的代码...
Dim driver As IWebDriver
Dim ChromeOptions As New ChromeOptions
driver = New ChromeDriver("C:\ChromeDriver", ChromeOptions)
driver.Navigate.GoToUrl("www.Google.com")
Dim doc As New HtmlDocument
Dim wb As New HtmlWeb
doc = wb.LoadFromBrowser(driver.PageSource)
Run Code Online (Sandbox Code Playgroud)
注意我的问题是关于 Selenium 和 HtmlAgilityPack 之间的交互。