[英]How can I create a website summary with Perl?
When you share something on Facebook or Digg, it generates some summary of the page. 当您在Facebook或Digg上共享内容时,它会生成页面的一些摘要。 How would I do this in Perl?
我将如何在Perl中做到这一点? What algorithms are there?
有什么算法?
For example: 例如:
If I go to Facebook and tried to share this question as a link: How can I create a website summary with Perl? 如果我去Facebook并尝试通过链接分享此问题: 如何使用Perl创建网站摘要?
It retrieves "Facebook/Digg get website summary? - Stack Overflow" as the title (which is just the title of the page) and [... incomplete question?] 它检索“ Facebook / Digg获取网站摘要?-堆栈溢出”作为标题(仅是页面标题)和[...不完整的问题?]
Assuming you mean sharing a link... 假设您的意思是共享链接...
Usually the summary is written by the user submitting the URL. 通常,摘要是由提交URL的用户编写的。 If you have to write a summary automagically this can be achieved by:
如果您必须自动编写摘要,可以通过以下方法实现:
Your best bet is to ask the user! 最好的选择是询问用户!
Hope that helps somewhat :) 希望能有所帮助:)
基本上,您想抓取URL并找到“最重要的段落”,它可能是第一个<h2>或<h1>之后的第一个<div>或<p>元素,具体取决于页面的布局。
您可以检查并查看页面上是否有元描述,但这使您不受编写元描述的任何人的影响。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.