Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/270.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何通过按钮检索URL? 3.88 mb 披头士乐队-嘿,裘德mp3_C# - Fatal编程技术网

C# 如何通过按钮检索URL? 3.88 mb 披头士乐队-嘿,裘德mp3

C# 如何通过按钮检索URL? 3.88 mb 披头士乐队-嘿,裘德mp3,c#,C#,我想知道如何检索链接的http://dc109.4shared.com/img/1038702204/8ffe01b/dlink__2Fdownload_2FxAdbDSb4_3Ftsid_3D20111224-60034-aa918a50/preview.mp3" 我问了很多次其他论坛和人,但我仍然不理解/不工作 我必须通过类“show1”获得它,因为还有其他类。如果您经常这样做,您可以使用第三方(开源)库HtmlAgilityPack,并使用XPath获取您的值(在线有很多资源) 创建Htm

我想知道如何检索链接的http://dc109.4shared.com/img/1038702204/8ffe01b/dlink__2Fdownload_2FxAdbDSb4_3Ftsid_3D20111224-60034-aa918a50/preview.mp3"

我问了很多次其他论坛和人,但我仍然不理解/不工作


我必须通过类“show1”获得它,因为还有其他类。

如果您经常这样做,您可以使用第三方(开源)库HtmlAgilityPack,并使用XPath获取您的值(在线有很多资源)

创建
HtmlDocument
(通过使用
HtmlWeb.Load
下载页面)后,我将使用以下方法获取URL:


String theLink=myDoc.DocumentNode.SelectSingleNode(//div[@class='show1']//a[.='Download'])。属性[“href”].Value

如果您经常这样做,您可以使用第三方(开源)库HtmlAgilityPack,并使用XPath获取您的值(在线有很多资源)

创建
HtmlDocument
(通过使用
HtmlWeb.Load
下载页面)后,我将使用以下方法获取URL:


String theLink=myDoc.DocumentNode.SelectSingleNode(//div[@class='show1']//a[.='Download'])。属性[“href”].Value

如果唯一独特的东西是文本,那么可以使用jQuery以这种方式执行:

<div id="song_html" class="show1">
    <div class="left">
        <!-- info mp3 here -->
        3.88 mb
    </div>
    <div id="right_song">
        <div style="font-size: 15px;">
            <b>Beatles - Hey Jude mp3</b></div>
        <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;">
                    <a href="javascript:void(0)" onclick="showPlayer(161498180, 'b7f231500894c321c0a7739802edff16965eb111', 'beatles', 'hey+jude')"
                        rel="nofollow" id="lk161498180" class="play_now">Play</a></div>
                <div style="margin-left: 8px; float: left;">
                    <a href="http://dc109.4shared.com/img/1038702204/8ffe01b/dlink__2Fdownload_2FxAdbDSb4_3Ftsid_3D20111224-60034-
                    aa918a50/preview.mp3" rel="nofollow" target="_blank" style="color: green;">Download</a></div>
                <div style="margin-left: 8px; float: left;">
                    <a href="javascript:void(0)" onclick="showEmbed(161498180,
                    'b7f231500894c321c0a7739802edff16965eb111')" rel="nofollow" id="em161498180" class="embed">
                        Embed</a></div>
                <div style="margin-left: 8px; float: left;">
                    <a href="http://www.ringtonematcher.com/go/?sid=WDLL&artist=beatles&song=hey+jude"
                        rel="nofollow" target="_blank" style="color: red;" title="Send Beatles - Hey Jude Ringtone to your Cell">
                        Send Ringtone</a></div>
                <div style="clear: both;">
                </div>
            </div>
            <div id="player161498180" style="float: left; margin-left: 10px;" class="player">
            </div>
        </div>
        <div style="clear: both;">
        </div>
    </div>
    <div style="clear: both;">
    </div>
</div>

希望这对您有所帮助

如果唯一的独特之处是文本,您可以使用jQuery:

<div id="song_html" class="show1">
    <div class="left">
        <!-- info mp3 here -->
        3.88 mb
    </div>
    <div id="right_song">
        <div style="font-size: 15px;">
            <b>Beatles - Hey Jude mp3</b></div>
        <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;">
                    <a href="javascript:void(0)" onclick="showPlayer(161498180, 'b7f231500894c321c0a7739802edff16965eb111', 'beatles', 'hey+jude')"
                        rel="nofollow" id="lk161498180" class="play_now">Play</a></div>
                <div style="margin-left: 8px; float: left;">
                    <a href="http://dc109.4shared.com/img/1038702204/8ffe01b/dlink__2Fdownload_2FxAdbDSb4_3Ftsid_3D20111224-60034-
                    aa918a50/preview.mp3" rel="nofollow" target="_blank" style="color: green;">Download</a></div>
                <div style="margin-left: 8px; float: left;">
                    <a href="javascript:void(0)" onclick="showEmbed(161498180,
                    'b7f231500894c321c0a7739802edff16965eb111')" rel="nofollow" id="em161498180" class="embed">
                        Embed</a></div>
                <div style="margin-left: 8px; float: left;">
                    <a href="http://www.ringtonematcher.com/go/?sid=WDLL&artist=beatles&song=hey+jude"
                        rel="nofollow" target="_blank" style="color: red;" title="Send Beatles - Hey Jude Ringtone to your Cell">
                        Send Ringtone</a></div>
                <div style="clear: both;">
                </div>
            </div>
            <div id="player161498180" style="float: left; margin-left: 10px;" class="player">
            </div>
        </div>
        <div style="clear: both;">
        </div>
    </div>
    <div style="clear: both;">
    </div>
</div>

希望这对您有所帮助。

您可以使用html解析来获取它,如图所示

简单的例子:

var href = $('a:text("Download")').attr('href');
我相信您是从4shared页面获取此HTML的,您可以使用
WebClient
类中的方法获取HTML


还有更简单的方法,使用API。

您可以使用html解析来获取它,如图所示

简单的例子:

var href = $('a:text("Download")').attr('href');
我相信您是从4shared页面获取此HTML的,您可以使用
WebClient
类中的方法获取HTML


还有更简单的方法,使用API。

您想使用Javascript/jQuery检索它吗?您真的需要发布所有HTML来问这个问题吗?你不能创建一个仍然有同样问题的小例子吗?你想用Javascript/jQuery检索它吗?你真的需要发布所有的HTML来问这个问题吗?你不能创建一个仍然有同样问题的小例子吗?你有到HtmlAgilityPack的链接吗?如果我使用它,用户也需要下载吗?。您可以将其用作DLL,因此用户需要它(但您可以将其包含在安装文件中或使用ILMerge(-尽管我没有使用此选项的经验)。您也可以将DLL放在与可执行文件相同的目录中。您是否有指向HtmlAgilityPack的链接?如果我使用它,用户是否也需要下载它?您可以将其用作DLL,因此是的,用户需要它(但您可以将其包含在安装文件中或使用ILMerge(-尽管我没有使用此选项的经验)。您也可以将DLL与可执行文件放在同一目录中。