Как получить мету от внешнего сайта и титульногополучить URL с внешнего сайта
Как получить мету от внешнего сайта
<input type="text"value="http://"id="externalurl" />
Как получить мету от внешнего сайта и титульногополучить URL с внешнего сайта
Как получить мету от внешнего сайта
<input type="text"value="http://"id="externalurl" />
Я бы лично идти об этом с помощью PHP, а не JavaScript. Если javascript действительно необходим, вы можете затем AJAX создать свою страницу PHP. Я хотел бы начать с помощью этой PHP библиотеки «http://sourceforge.net/projects/simplehtmldom/» Затем сделать что-то вдоль линий этого:
// Create DOM from URL or file
$url = 'http://www.example.com/';
$html = file_get_html($url);
// Find all meta tags
foreach($html->find('meta') as $element){
$temp['name'] = $element->name;
$temp['content'] = $element->content;
$meta[] = $temp;
}
//Run checks on the array of meta tags or whatever you are trying to acheive
Я не проверил это, как я измотан, но я видел этот вопрос, и мысль этой библиотеки сразу! Надеюсь, что это помогает
EDIT ПОСЛЕ ИСПЫТАНИЙ: После недолгого пьесы, этот код:
<?php
include('simple_html_dom.php');
// Create DOM from URL or file
$url = 'http://www.amazon.com/';
$html = file_get_html($url);
// Find all meta tags
foreach($html->find('meta') as $element){
$temp['name'] = $element->name;
$temp['content'] = $element->content;
$temp['charset'] = $element->charset;
$meta[] = $temp;
$temp = "";
}
print_r($meta);
?>
Выходы:
Array
(
[0] => Array
(
[name] =>
[content] => on
[charset] =>
)
[1] => Array
(
[name] =>
[content] => text/html; charset=iso-8859-1
[charset] =>
)
[2] => Array
(
[name] => description
[content] => Online shopping from the earth's biggest selection of books, magazines, music, DVDs, videos, electronics, computers, software, apparel & accessories, shoes, jewelry, tools & hardware, housewares, furniture, sporting goods, beauty & personal care, broadband & dsl, gourmet food & just about anything else.
[charset] =>
)
[3] => Array
(
[name] => keywords
[content] => Amazon, Amazon.com, Books, Online Shopping, Book Store, Magazine, Subscription, Music, CDs, DVDs, Videos, Electronics, Video Games, Computers, Cell Phones, Toys, Games, Apparel, Accessories, Shoes, Jewelry, Watches, Office Products, Sports & Outdoors, Sporting Goods, Baby Products, Health, Personal Care, Beauty, Home, Garden, Bed & Bath, Furniture, Tools, Hardware, Vacuums, Outdoor Living, Automotive Parts, Pet Supplies, Broadband, DSL
[charset] =>
)
[4] => Array
(
[name] => google-site-verification
[content] => 9vpzZueNucS8hPqoGpZ5r10Nr2_sLMRG3AnDtNlucc4
[charset] =>
)
)
Который, как представляется, в значительной степени все!