Php 构建一个简单的链接预览器/linter
我希望能够从给定的URL抓取网页标题,就像Facebook和最近的Google plus有一个链接预览器一样,但更加简化Php 构建一个简单的链接预览器/linter,php,ajax,Php,Ajax,我希望能够从给定的URL抓取网页标题,就像Facebook和最近的Google plus有一个链接预览器一样,但更加简化 有没有关于如何做的提示/提示?最好使用jQuery //get_new_title.php: <?php if ($_GET['link'] == "#new_stuff") { echo "My site name - New STUFF!!!"; } if ($_GET['link'] == "#other stuff") { echo "My s
有没有关于如何做的提示/提示?最好使用jQuery //get_new_title.php:
<?php
if ($_GET['link'] == "#new_stuff")
{
echo "My site name - New STUFF!!!";
}
if ($_GET['link'] == "#other stuff")
{
echo "My site name - Some other stuff";
}
最好使用jQuery //get_new_title.php:
<?php
if ($_GET['link'] == "#new_stuff")
{
echo "My site name - New STUFF!!!";
}
if ($_GET['link'] == "#other stuff")
{
echo "My site name - Some other stuff";
}
如果您是在php上编写的,这应该可以完成您的工作
function getdoctitle($link) {
$lines = @file($link);
$str=implode(”\n”,$lines);
$str=preg_match('/<title>([^>]*)<\/title>/si', $str, $matches );
if (strpos(” $str”,”<title>”) and strpos(” $str”,”</title>”)) {
$a1=explode(”<title>”,$str);
$str2=$a1[1];
$a2=explode(”</title>”,$str2);
$str3=$a2[0];
return $str3;
} else {
return “”;
}
}
函数getdoctitle($link){
$lines=@file($link);
$str=内爆(“\n”,$line);
$str=preg_match('/([^>]*)/si',$str,$matches);
if(strpos(“$str”,”)和strpos(“$str”,”)){
$a1=爆炸(“,$str”);
$str2=$a1[1];
$a2=爆炸(“,$str2”);
$str3=$a2[0];
返回$str3;
}否则{
返回“”;
}
}
如果您是在php上编写,这应该可以完成您的工作
function getdoctitle($link) {
$lines = @file($link);
$str=implode(”\n”,$lines);
$str=preg_match('/<title>([^>]*)<\/title>/si', $str, $matches );
if (strpos(” $str”,”<title>”) and strpos(” $str”,”</title>”)) {
$a1=explode(”<title>”,$str);
$str2=$a1[1];
$a2=explode(”</title>”,$str2);
$str3=$a2[0];
return $str3;
} else {
return “”;
}
}
函数getdoctitle($link){
$lines=@file($link);
$str=内爆(“\n”,$line);
$str=preg_match('/([^>]*)/si',$str,$matches);
if(strpos(“$str”,”)和strpos(“$str”,”)){
$a1=爆炸(“,$str”);
$str2=$a1[1];
$a2=爆炸(“,$str2”);
$str3=$a2[0];
返回$str3;
}否则{
返回“”;
}
}
但这是如何获得链接标题的?我想预览链接的标题,而不是我正在查看的文档-指向其他网站的链接。链接的标题?例如,你想从
中获取标题?你知道当你在Facebook上发布一个链接时,它会关闭并从该页面获取标题和一些图像。我想建立一个简单的版本。谢谢你的帮助,我发现了一个很好的插件YAAAWN,你的意思是HOVERCARD!aaah:)但这是如何获得链接标题的?我想预览链接的标题,而不是我正在查看的文档-指向其他网站的链接。链接的标题?例如,你想从
中获取标题?你知道当你在Facebook上发布一个链接时,它会关闭并从该页面获取标题和一些图像。我想建立一个简单的版本。谢谢你的帮助,我发现了一个很好的插件YAAAWN,你的意思是HOVERCARD!啊啊:)