【发布时间】:2019-06-26 10:17:09
【问题描述】:
我正在尝试编写一种使用 webBrowser1 通过 href 获取下载链接的方法,但问题是我必须使用它的类名找到它。
<body>
<iframe scrolling="no" frameborder="0" allowtransparency="true" tabindex="0" name="twttrHubFrame" style="position: absolute; top: -9999em; width: 10px; height: 10px;" src="http://platform.twitter.com/widgets/hub.html">
¶
<div id="main">
¶→
<div id="header">
<div style="float:left;">
¶→
<div id="content">
¶→
<h1 style="background-image:url('http://static.mp3skull.com/img/bgmen.JPG'); background-repeat:repeat-x;">Rush·Mp3·Download</h1>
¶→
<a id="bitrate" onclick="document.getElementById('ofrm').submit(); return false;" rel="nofollow" href="">
<form id="ofrm" method="POST" action="">
¶→¶→→
<div id="song_html" class="show1">
¶→→→
<div class="left">
¶→→→
<div id="right_song">
¶→→→→
<div style="font-size:15px;">
¶→→→→
<div style="clear:both;"></div>
¶→→→→
<div style="float:left;">
¶→→→→→
<div style="float:left; height:27px; font-size:13px; padding-top:2px;">
¶→→→→→→
<div style="float:left; width:27px; text-align:center;">
¶→→→→→→
<div style="margin-left:8px; float:left;">
<a style="color:green;" target="_blank" rel="nofollow" href="http://dc182.4shared.com/img/1011303409/865387c9/dlink__2Fdownload_2F6QmedN8H_3Ftsid_3D20111211-54337-a79f8d10/preview.mp3">Download</a>
</div>
·¶→→→→→→
<div style="margin-left:8px; float:left;">
¶→→→→→→
<div style="margin-left:8px; float:left;">
·¶→→→→→→
<div style="clear:both;"></div>
¶→→→→→
</div>
¶→→→→→
<div id="player155580779" class="player" style="float:left; margin-left:10px;"></div>
¶→→→→
</div>
→¶→→→→
<div style="clear:both;"></div>
¶→→→
</div>
¶→→→
<div style="clear:both;"></div>
¶→→
</div>
我在 google 上找遍了,但我找到了 PHP 示例?
我知道你会这样做
HtmlElement downloadlink = webBrowser1.Document.GetElementById("song_html").All[0];
URL = downloadlink.GetAttribute("href");
但我不明白“show1”类如何做到这一点。
请通过示例和/或我可以访问的网站为我指明正确的方向,这样我就可以在搜索时学习如何执行此操作并且不知道。
编辑:我非常需要 href 链接(“http://dc182.4shared.com/img/1011303409/865387c9/dlink__2Fdownload_2F6QmedN8H_3Ftsid_3D20111211-54337-a79f8d10/preview.mp3”),那么我该如何获得它?
【问题讨论】:
-
“show1”和“webBrowser1”从何而来?如果您使用示例代码或库,请包含该信息。
-
show1 是我在上面发布的 HTML 代码中的类名。 webBrowser1 就是我用来通过表单访问网页的工具。
标签: c# webbrowser-control