PHP的刮板需要CSV和图像下载

我使用此刮板获取所有内容和图像,我从一个产品页面开始,然后跟随产品链接到其页面并从这些页面中提取数据。我不确定如何使用刮板创建CSV文件以及如何将图像从页面下载到计算机上的文件夹中。帮助解决此问题将不胜感激。我的代码在下面。

<?php
  include('simple_html_dom.php');

  $html = file_get_html('https://somelink.com/products');

$links = array();
  foreach($html->find('#catalog-listing .category-products .yt-products-container .products-grid .product-info .product-name a') as $a) {
    $links[] = $a->href;
}

  foreach($links as $link) {
    echo '"'.$link.'",';

    $html2 = file_get_html($link);
      foreach($html2->find('.container form .product-shop .product-name h1') as $title) {
        echo '"'.$title->plaintext.'",';
      }
      foreach($html2->find('.container form .product-shop .price-box .price') as $price) {
        echo '"'.$price->plaintext.'",';
      }
      foreach($html2->find('#yt_tab_products .tab-content .std p') as $description ) {
        echo '"'.$description->plaintext.'",';
      }
      foreach($html2->find('.container .short-description ul li') as $feature ) {
        echo $feature->plaintext.'|';
      }

        foreach($html2->find('.container .product-essential .product-img-box .more-views ul li a') as $img ) {
          echo $img->href;
        }
      echo "<br>";
      echo "<br>";

    }
jieci1981 回答:PHP的刮板需要CSV和图像下载

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3130601.html

大家都在问