Home >Backend Development >PHP Tutorial >PHP intercepts remote web page information_PHP tutorial

PHP intercepts remote web page information_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:50:19822browse

The following program code will introduce how to intercept remote web page information, including Title, Description and Keywords in the HTML tag:

PLAIN TEXT
PHP:
//—–Define the web page address to be intercepted
$url = "http:// www.2cto.com ";
//—– Read the source code of the web page
$fp = file_get_contents($url);
//—– Intercept title information
preg_match(“/(.*)/s”, $fp, $match);
$title = $match[1];
//—– Intercept Description and Keywords
$metatag = get_meta_tags($url);
$description = $metatag["description"];
$keywords = $metatag["keywords"];
//—–Print the results
echo “URL: $urln”;
echo “Title: $titlen”;
echo “Description: $descriptionn”;
echo “Keywords: $keywordsn”;
?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/478263.htmlTechArticleThe following program code will introduce how to intercept remote web page information, including Title, Description and Keywords in the HTML tag: PLAIN TEXT PHP: ?php //Define the web page address to be intercepted $url = ht...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn