3

私はこのJavaScriptを持っています

 <script>
    var s_u ="go_r.php";
        var con ="df7cf40eca520dc1ba6941a30cbffc23";
        var idm ="65212";
        var sass ="0";
        var n_x =naxer();


        var urgo='http://www.storebox1.info/v916?product_name=umbrella.mp3&filesize=4.29&product_title=umbrella.mp3&installer_file_name=umbrella.mp3&product_file_name=umbrella.mp3.mp3&product_download_url=http://cicloturismocordoba.com/musica/2010/umbrella.mp3&reffer=http://beemp3.com//download.php?file=65212&song=Umbrella;'
    function show_url(url){


    document.getElementById("ssilka").innerHTML='<div class="download-link"><strong><a href="'+url+'" onClick="createCookieIzr();window.open(\''+urgo+'\');return false;" target="_blank" rel="nofollow" class="a-load-link"><span>Download Now</span>From cicloturismocordoba.com<br> The Baseballs - Umbrella .mp3</a></strong><div class="fr"><a href="#" rel="nofollow" onclick="window.open(\'help.html\',\'Report\', \'location,width=500,height=420\');return false;">Got a Problem? Read help</a><br>or &nbsp;<a href="" onclick="window.open(\'report.php?file=65212\',\'Report\', \'location,width=250,height=250\');return false;" rel="nofollow"> Report broken link</a></div><em><font color="red">Right click on the link and choose "save target as" to download this mp3</font><br><span class="black">Visit The Baseballs official site - <a target="_blank" rel="nofollow" href=http://www.the-baseballs.com>http://www.the-baseballs.com</a></em><div class="url-code" style="padding-left:0px;padding-top:15px;"><span class="title-url" style="width:50px;"><b>MP3 URL:</b></span><input style="width:300px;" type="text" value="'+url+'" onClick="this.select();" readonly="readonly"></div><small>Clicking "Download mp3" button, you agree with our <a href="/tou.html" rel="nofollow">Terms and conditions</a>.<br>Also you can <a rel="nofollow" href="/copy_report.php?file=65212&song=Umbrella" target="_blank">Report copyrighted link</a></small><hr size="1" color="#cccccc" noshade="noshade" style="margin-bottom:5px;margin-top:5px;"></div>';
    }
    function show_embed(url)
    {
    embedDivCodeMP3 = '<div style="background:url(http://beemp3.com/images/beemp3-player.png) 100% 50% no-repeat #fffbf2;border:solid 1px #ffbe32;font:11px/16px arial, sans-serif;color:#000;padding:4px 11px 0;border-radius:5px;width:390px;margin:0 0 14px"><p style="margin:0;padding:0 0 4px;font-size:11px"><a href="#" style="color:#2793D8">The Baseballs - Umbrella .mp3</a></p><div class="player"><embed class="beeplaer" wmode="transparent" style="height:24px;width:290px;" src="http://beemp3.com/player/player.swf" quality="high" bgcolor="#ffffff" width="290" height="24" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="playerID=1&bg=0xCDDFF3&leftbg=0x357DCE&lefticon=0xF2F2F2&rightbg=0x64F051&rightbghover=0x1BAD07&righticon=0xF2F2F2&righticonhover=0xFFFFFF&text=0x357DCE&slider=0x357DCE&track=0xFFFFFF&border=0xFFFFFF&loader=0xAF2910&soundFile='+escape(url)+'"></embed></div><p style="margin:0;font-size:11px;text-align:center;padding:6px 0 5px">Found at <a href="http://beemp3.com/download.php?file=65212&song=Umbrella" style="color:#2793D8">bee mp3 search engine</a></p></div>';
    embedTableCodeMP3 = '<table style="background:url(http://beemp3.com/images/beemp3-player.png) 100% 50% no-repeat #fffbf2;border:solid 1px #ffbe32;font:11px/16px arial, sans-serif;color:#000;border-radius:5px;width:320px;margin:0 0 14px"><tr><td style="padding:4px 11px 0"><p style="margin:0;padding:0 0 4px;font-size:11px"><a href="#" style="color:#2793D8">The Baseballs - Umbrella .mp3</a></p><div class="player"><embed class="beeplaer" wmode="transparent" style="height:24px;width:290px;" src="http://beemp3.com/player/player.swf" quality="high" bgcolor="#ffffff" width="290" height="24" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="playerID=1&bg=0xCDDFF3&leftbg=0x357DCE&lefticon=0xF2F2F2&rightbg=0x64F051&rightbghover=0x1BAD07&righticon=0xF2F2F2&righticonhover=0xFFFFFF&text=0x357DCE&slider=0x357DCE&track=0xFFFFFF&border=0xFFFFFF&loader=0xAF2910&soundFile='+escape(url)+'"></embed></div><p style="margin:0;font-size:11px;text-align:center;padding:6px 0 5px">Found at <a href="http://beemp3.com/download.php?file=65212&song=Umbrella" style="color:#2793D8">bee mp3 search engine</a></p></td></tr></table>';
        document.getElementById('embb').innerHTML='<div class="beemp3-player"><br><div class="wrap-beemp3-player"><p><a href="http://beemp3.com/download.php?file=65212&song=Umbrella">The Baseballs - Umbrella .mp3</a></p><div class="player" onclick="javascript:clickonplayer();"><embed class="beeplaer" wmode="transparent" style="height:24px;width:290px;" src="http://beemp3.com/player/player.swf" quality="high" bgcolor="#ffffff" width="290" height="24" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="playerID=1&bg=0xCDDFF3&leftbg=0x357DCE&lefticon=0xF2F2F2&rightbg=0x64F051&rightbghover=0x1BAD07&righticon=0xF2F2F2&righticonhover=0xFFFFFF&text=0x357DCE&slider=0x357DCE&track=0xFFFFFF&border=0xFFFFFF&loader=0xAF2910&soundFile='+escape(url)+'"></embed></div><p class="beemp3-search-link">Found at <a href="http://beemp3.com/download.php?file=65212&song=Umbrella">bee mp3 search engine</a></p></div></div><strong class="title-player">Copy and Paste Code to your site, blog or forum</strong><div class="embed-beemp3"><div class="select-embed-code" style="padding: 0 0 5px"><a href="#" class="div-code active"><span>div</span></a><a href="#" class="table-code"><span>table</span></a><em>(select code type)</em></div><textarea cols="70" rows="1" id="embed-code-mp3" readonly="readonly" style="width:390px;">Div code get here</textarea></div>';
        //if (_ge('adscr')){document.getElementById('embb').appendChild(document.getElementById('adscr'));_ge('adscr').innerHTML="<br>"+_ge('adscr').innerHTML;}
        //else {document.getElementById('embb').innerHTML='<div class="beemp3-player"><br><div class="wrap-beemp3-player"><p><a href="http://beemp3.com/download.php?file=65212&song=Umbrella">The Baseballs - Umbrella .mp3</a></p><div class="player" onclick="javascript:clickonplayer();"><embed class="beeplaer" wmode="transparent" style="height:24px;width:290px;" src="http://beemp3.com/player/player.swf" quality="high" bgcolor="#ffffff" width="290" height="24" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="playerID=1&bg=0xCDDFF3&leftbg=0x357DCE&lefticon=0xF2F2F2&rightbg=0x64F051&rightbghover=0x1BAD07&righticon=0xF2F2F2&righticonhover=0xFFFFFF&text=0x357DCE&slider=0x357DCE&track=0xFFFFFF&border=0xFFFFFF&loader=0xAF2910&soundFile='+escape(url)+'"></embed></div><p class="beemp3-search-link">Found at <a href="http://beemp3.com/download.php?file=65212&song=Umbrella">bee mp3 search engine</a></p></div></div><strong class="title-player">Copy and Paste Code to your site, blog or forum</strong><div class="embed-beemp3"><div class="select-embed-code" style="padding: 0 0 5px"><a href="#" class="div-code active"><span>div</span></a><a href="#" class="table-code"><span>table</span></a><em>(select code type)</em></div><textarea cols="70" rows="1" id="embed-code-mp3" readonly="readonly" style="width:390px;">Div code get here</textarea></div>';}
    $("#embed-code-mp3").val(embedDivCodeMP3);
    $("#embed-code").click(function(){$(this).select();});
    $("#embed-code-mp3").click(function(){$(this).select();});
    $(".select-embed-code a").click(function(){$(this).addClass("active").siblings(".active").removeClass("active");setEmbedCode($(this).parents(".select-embed-code"));return false;});
    $(".select-embed-code").each(function(){setEmbedCode($(this));});
    }
    </script>

Webview の stringByEvaluatingJavaScriptFromString メソッドを使用して、var con、var idmの値を取得する必要があります。

助けてください

4

1 に答える 1

0

次のようなものを使用できます

NSString *scriptString = [webView stringByEvaluatingJavaScriptFromString: 
                           @"document.getElementsByTagName('script')[0].innerHTML"];

JavaScript を取得します。

その後、1 つの可能性として、正規表現を使用して要求された変数を取得することができます。

NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"var con =\"(\\w*)\";"
                                                                       options:NSRegularExpressionCaseInsensitive
                                                                         error:&error];
NSArray *matches = [regex matchesInString:scriptString
                                  options:0
                                    range:NSMakeRange(0, [scriptString length])];
// The capture group would be at index '1'
if ([matches count] > 0 && [matches[0] rangeAtIndex:1].location != NSNotFound) {
    NSLog(@"%@", [scriptString substringWithRange:[matches[0] rangeAtIndex:1]]);
}

その他のオプションと可能性については、docsを確認してください。

于 2013-03-15T10:10:55.677 に答える