PHP在本地抓取和存储输出

PHP在本地抓取和存储输出,php,html,storage,scrape,Php,Html,Storage,Scrape,我有一个从atom提要中提取信息的小PHP脚本。然后将回音推入文件或数据库的最佳方式是什么?我希望能够每小时参考这些信息 比如说 PHP grabs HTML page. Webserver stores the resulting HTML locally. Webserver references that locally stored HTML. Webserver displays a template version of the local information. 以下是拉动ht

我有一个从atom提要中提取信息的小PHP脚本。然后将回音推入文件或数据库的最佳方式是什么?我希望能够每小时参考这些信息

比如说

PHP grabs HTML page.
Webserver stores the resulting HTML locally.
Webserver references that locally stored HTML.
Webserver displays a template version of the local information.
以下是拉动html的php:

<?php include('simple_html_dom.php'); echo file_get_html('http://www.website.com')->plaintext[1] ; ?>

您可以使用非常简单的
文件内容()。


希望这能对…有所帮助

<html>
<head>
<title>Online PHP Script Execution</title>
</head>
<body>
<?php require'simple_html_dom.php'; ?>
<?php
    $url_path='http://www.google.com/';
    $create=fopen("folder/"."index.html",'w+') or die("can't open file");
    $src=file_get_html($url_path)->plaintext ;
    $write=fwrite($create,$src);
        fclose($create);

    foreach($html->find('script') as $script)   //get script 
            {

                    $scriptPath=$script->src;
                    $js = explode("/", $scriptPath);
                    $jsName = end($js);
             $path="";
                  for ($i=0;$i<(count($image)-1);$i++) 
                      {
                        $path .= $image[$i] . "/";
                        if(!file_exists('folder/'.$path))
                            {
                                mkdir('folder/'.$path, 0777, true);     //jquery folder created
                            }       
                      }
                    file_put_contents('folder/'.$path.$jsName,file_get_contents($url_path.$scriptPath)); //all jquery downloaded
            }

        foreach($html->find('img') as $img)     //image
                {

                    $imgpath=$img->src;
                    $image = explode("/", $imgpath);
          $path="";
                      for ($i=0;$i<(count($image)-1);$i++) 
                      {
                        $path .= $image[$i] . "/";
                        if(!file_exists('folder/'.$path))
                            {
                                mkdir('folder/'.$path, 0777, true);     //img folder created
                            }       
                      }

                    $imgName = end($image);
                        file_put_contents('folder/'.$path.$imgName,file_get_contents($url_path.$imgpath));  //img downloaded

                } 

        foreach($html->find('link') as $link)  //get link 
                {
                        if(strtolower($link->getAttribute('rel')) == "stylesheet" ) 
                        {
                            $linkpath=$link->getAttribute('href');
                        }

                        $links = explode("/", $linkpath);
                        $linkName = end($links);
                      $path="";
                  for ($i=0;$i<(count($image)-1);$i++) 
                      {
                        $path .= $image[$i] . "/";
                        if(!file_exists('folder/'.$path))
                            {
                                mkdir('folder/'.$path, 0777, true);     //css folder created
                            }       
                      }

                            file_put_contents('folder/'.$path.$linkName,file_get_contents($url_path.$linkpath));    //download css
                        }
?>
</body>
</html>

在线PHP脚本执行

你们太棒了,只要我能给你们投票,我就来投票支持你们。
<html>
<head>
<title>Online PHP Script Execution</title>
</head>
<body>
<?php require'simple_html_dom.php'; ?>
<?php
    $url_path='http://www.google.com/';
    $create=fopen("folder/"."index.html",'w+') or die("can't open file");
    $src=file_get_html($url_path)->plaintext ;
    $write=fwrite($create,$src);
        fclose($create);

    foreach($html->find('script') as $script)   //get script 
            {

                    $scriptPath=$script->src;
                    $js = explode("/", $scriptPath);
                    $jsName = end($js);
             $path="";
                  for ($i=0;$i<(count($image)-1);$i++) 
                      {
                        $path .= $image[$i] . "/";
                        if(!file_exists('folder/'.$path))
                            {
                                mkdir('folder/'.$path, 0777, true);     //jquery folder created
                            }       
                      }
                    file_put_contents('folder/'.$path.$jsName,file_get_contents($url_path.$scriptPath)); //all jquery downloaded
            }

        foreach($html->find('img') as $img)     //image
                {

                    $imgpath=$img->src;
                    $image = explode("/", $imgpath);
          $path="";
                      for ($i=0;$i<(count($image)-1);$i++) 
                      {
                        $path .= $image[$i] . "/";
                        if(!file_exists('folder/'.$path))
                            {
                                mkdir('folder/'.$path, 0777, true);     //img folder created
                            }       
                      }

                    $imgName = end($image);
                        file_put_contents('folder/'.$path.$imgName,file_get_contents($url_path.$imgpath));  //img downloaded

                } 

        foreach($html->find('link') as $link)  //get link 
                {
                        if(strtolower($link->getAttribute('rel')) == "stylesheet" ) 
                        {
                            $linkpath=$link->getAttribute('href');
                        }

                        $links = explode("/", $linkpath);
                        $linkName = end($links);
                      $path="";
                  for ($i=0;$i<(count($image)-1);$i++) 
                      {
                        $path .= $image[$i] . "/";
                        if(!file_exists('folder/'.$path))
                            {
                                mkdir('folder/'.$path, 0777, true);     //css folder created
                            }       
                      }

                            file_put_contents('folder/'.$path.$linkName,file_get_contents($url_path.$linkpath));    //download css
                        }
?>
</body>
</html>