case '£': $priceUnit = 'GBP'; break; default: $priceUnit = 'USD'; break; } //调用产品信息类 $productDetail = new ProductDetails(); $productHtml = $productDetail->getHtml($url); // $productDetailInformation = $productDetail->getProductDetails($url); echo 'FilaMent List: Index ----' . $index . '<br/>'; echo 'Picture link : ' . $imageUrl . '<br/>' . 'Name : ' . $materialType . '<br/>' . 'Link : ' . $startUrl . '<br/>' . 'Manufacture : ' . $producer . '<br/>' . 'Price : ' . $price; echo '<br/>---------------------------------------------------------------------<br/>'; $diameterIndex = $productDetail->setDiameterIndex($url); $diameterInfo = $productDetail->getDiameters($productHtml, $diameterIndex); $weightInfo = $productDetail->getWeight($productHtml); $colorInfo = $productDetail->getColor($productHtml); $description = $productDetail->getFeatures($productHtml); $diameter = $diameterInfo['diameter']; $diameterUnit = $diameterInfo['diameterUnit']; $weight = $weightInfo['weight']; $weightUnit = $weightInfo['weightUnit']; $packForm = $weightInfo['packForm']; $weightInKg = $weightInfo['weightInKg']; $colorNames = $colorInfo['colorNames']; $colorImgUrls = $colorInfo['colorImgUrls']; //没有颜色 if (count($colorNames) == 0) { $productXml = $xml->addchild("product"); $idXml = $productXml->addAttribute("id", $index);
ob_implicit_flush(1); //立即输出 foreach ($content[0]->find('a') as $element) { $hrefStr = $companyUrl . $element->href; $productName = strtolower($element->plaintext); echo $hrefStr . '--' . $productName . '<br/>'; //abs,pla直径信息 $diameterInformation = array(); //调用产品信息类 $productDetails = new ProductDetails(); $productHtml = $productDetails->getHtml($hrefStr); $productDetailFromJs = new ProductDetailsFromJS(); $productInfo = array(); if (strcasecmp($productName, 'abs') == 0) { $productInfo = $productDetailFromJs->getAbsProductInfo($productHtml, $productName); $diameterInformation = $productDetails->getDiameters($productHtml); } else { if (strcasecmp($productName, 'pla') == 0) { $productInfo = $productDetailFromJs->getPlaProductInfo($productHtml, $productName); $diameterInformation = $productDetails->getPlaDiameters($productHtml); } } //图片 if (strcasecmp($productName, 'pla') == 0) { $imageUrl = $productDetails->getPlaImage($productHtml); } else { $imageUrl = $productDetails->getImage($productHtml); } //描述 $description = $productDetails->getFeatures($productHtml, $productName); if (strcasecmp($productName, 'dissolvable') == 0) {