我尝试使用System.Net.WebClient.downloadstring方法
下载网页源代码地址是这样的:“http://www.example.com/aaa/?only=true” 当我尝试将此地址下载到字符串时,我只看到谷歌网站源
下载了这样的字符串:“Google(function(){window.google = {kEI:'J_THVK_NHMLwUIGlgJAC',kEXPI:'4” 等...
这是我的代码:
Dim webClient As System.Net.WebClient = New System.Net.WebClient()
If bEncode = True Then
webClient.Encoding = System.Text.Encoding.UTF8
End If
Dim strResult As String = webClient.DownloadString("http://www.example.com/aaa/?only=true")
但是在网络浏览器中,我看到普通的html,当我看到clcik view-source时,这是正常的。
为什么我无法将页面源代码下载到我的字符串中?为什么要下载谷歌字符串?
非常感谢。
添加了备注:
**很抱歉我的英语不好。
答案 0 :(得分:1)
我可以使用HttpClient
获取该html页面HttpClient client = new HttpClient();
var html = await client.GetStringAsync("http://www.betbrain.com/football/brazil/cearense-1/horizonte-v-sao-benedito-ce/1x2/full-time-excluding-overtime/?only=true&attempt=1");
以
开头<div id="oddsDetailRTFDisabled" class="hidden">
<div class="FormMessage FormError">
<span class="FormIcon">MESSAGES:</span>
<h2 class="FormTitle">Real time updates disabled</h2>
<p class="FormP">The automatic updates don't work if there are more than four Odds pages (tabs) opened with the same browser. If this is not the case try clearing your browser's cache (temporary internet files).</p>
</div>
</div>
......