且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

PHP中的Web爬虫链接/页面逻辑

更新时间:2023-02-26 13:27:23

首先,正则表达式和HTML不混用。使用:

First of all, regex and HTML don't mix. Use:

foreach(DOMDocument::loadHTML($source)->getElementsByTagName('a') as $a)
{
  $a->getAttribute('href');
}

可能在您网站之外的链接以协议或 // ,即

Links that may go outside your site start with protocol or //, i.e.

http://example.com
//example.com/

href =google.com是本地文件的链接。

但是如果你想创建一个网站的静态副本,为什么不使用 wget

But if you want to create static copy of a site, why not just use wget?