我一直在谷歌搜索一段时间,但找不到很好的答案。我使用httpclient发布了一个非常奇怪的表单,它没有方法属性,子元素没有名称属性。表单如下:
<form action="#" novalidate="" data-ember-action="" data-ember-action-12="12">
<div data-components="pdr-signin-form" id="ember13" class="ember-view">
<div data-components="pdr-signin-id" id="ember14" class="ember-view">
<div data-components="pdr-text-field" id="ember15" class="ember-view"><div>
<div class="textfield-input-wrapper">
<input dir="ltr" autocomplete="on" title="Sign-In ID (Email Address)" tabindex="2" placeholder="Sign-In ID (Email Address)" maxlength="63" id="ember16" class="textfield ember-text-field ember-view" type="email">
</div>
<!----></div>
<!----></div>
</div>
<div data-components="pdr-password-input" id="ember17" class="ember-view">
<div data-components="pdr-text-field-v2" id="password" class="ember-view"><div>
<div class="textfield-input-wrapper">
<input dir="ltr" autocomplete="off" title="Password" tabindex="2" placeholder="Password" maxlength="30" id="ember18" class="textfield ember-text-field ember-view" type="password">
</div>
</div>
<!----></div>
<button tabindex="2" title="Password Display Off" class="icon-disp-password disp-icon-off" type="button" data-ember-action="" data-ember-action-19="19">
</button>
</div>
</div>
这是我使用的代码:
Async Function DownloadPageAsync() As Task(Of String)
Dim page As String = "myurl"
Dim values As New Dictionary(Of String, String) From {{"ember16", "nathantodd7@yahoo.com"}, {"ember18", "nathantodd7@yahoo.com"}}
Dim content As Object = New FormUrlEncodedContent(values)
Using client As HttpClient = New HttpClient()
Using response As HttpResponseMessage = Await client.GetAsync(page)
Using contents As HttpContent = response.Content
' Get contents of page as a String.
Dim result As String = Await contents.ReadAsStringAsync()
Return result
End Using
End Using
End Using
End Function