Home > Backend Development > PHP Tutorial > PHP obtains the implementation code of web page source code and web page title

PHP obtains the implementation code of web page source code and web page title

WBOY
Release: 2016-07-25 08:56:20
Original
1434 people have browsed it
  1. $lines = file('http://bbs.it-home.org/');
  2. foreach ($lines as $line_num => $line) {
  3. echo "Line {$line_num} : " . htmlspecialchars($line) . "
    n";
  4. }
  5. ?>
复制代码

2,获取网页的标题:

  1. $url = 'http://bbs.it-home.org';
  2. $lines_array = file($url);
  3. echo $lines_array;
  4. echo "
    ";
  5. $lines_string = implode('', $lines_array);
  6. eregi("(.*)", $lines_string, $head);
  7. echo "head:".$head;
  8. echo "
    ";
  9. print_r($head);
  10. echo "
    ";
  11. echo "title:".$head[1];
  12. ?>
复制代码


source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template