Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/263.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
基于PHP的web刮刀_Php_Html_Scrape - Fatal编程技术网

基于PHP的web刮刀

基于PHP的web刮刀,php,html,scrape,Php,Html,Scrape,我想做的是使用PHP从我输入参数的url中抓取一个网站 我想要完整的原始源代码。。但这还不是全部 然后我想将它保存到一个html页面中,并保存到php脚本的本地服务器上 有一个简单的片段吗?或者有人能很容易地给我写一个代码吗 比如说 我要刮 例如,mysite.com/scrape.php?url=http://google.com 我想让它将google的首页保存到这里有一个脚本,可以将指定url的内容保存到名为scraped.html的文件中: if (isset($_GET['url'])

我想做的是使用PHP从我输入参数的url中抓取一个网站

我想要完整的原始源代码。。但这还不是全部

然后我想将它保存到一个html页面中,并保存到php脚本的本地服务器上

有一个简单的片段吗?或者有人能很容易地给我写一个代码吗

比如说

我要刮

例如,mysite.com/scrape.php?url=http://google.com


我想让它将google的首页保存到

这里有一个脚本,可以将指定url的内容保存到名为
scraped.html的文件中:

if (isset($_GET['url'])):
   $contents = file_get_contents($_GET['url']);
   file_put_contents('scraped.html', $contents);
endif;
要在调用
file\u get\u contents()
时使用url,必须在
php.ini
文件中启用


当然,这只会保存请求url的实际来源,而不会保存任何其他资源,例如图像、脚本和样式表。

通过
scrap
您的意思是
下载
?查看
文件获取内容()
文件放置内容()