❇️ Permet l'enregistrement de plusieurs images
This commit is contained in:
parent
348ebfb170
commit
272ab042d7
@ -2,6 +2,8 @@
|
||||
|
||||
namespace Shikiryu\LBCReposter;
|
||||
|
||||
use Symfony\Component\DomCrawler\Crawler;
|
||||
|
||||
class Deal
|
||||
{
|
||||
const TYPE_OFFER = 's';
|
||||
@ -48,11 +50,22 @@ class Deal
|
||||
$deal->setType(self::TYPE_OFFER);
|
||||
$deal->setBody($crawler->filter('.properties_description')->first()->filter('p')->eq(1)->text());
|
||||
$deal->setPrice($crawler->filter('[itemprop=price]')->first()->attr('content'));
|
||||
if ($crawler->filter('.item_photo')->count() > 0) {
|
||||
$script = $crawler ->filter('.item_photo')->first()->nextAll()
|
||||
->filter('script')->first()->html();
|
||||
preg_match_all("/\"(http.*ad-thumb.*)\"/m", $script, $urls);
|
||||
$urls = $urls[1];
|
||||
$images = [];
|
||||
foreach ($urls as $i => $url) {
|
||||
$images[] = [sprintf('setImage%s', $i) => str_replace('thumb','large', $url)];
|
||||
}
|
||||
} else {
|
||||
$images = $crawler->filter('[data-popin-content]')->each(
|
||||
function ($node, $i) {
|
||||
function (Crawler $node, $i) {
|
||||
return [ sprintf('setImage%s', $i) => $node->attr('data-popin-content')];
|
||||
}
|
||||
);
|
||||
}
|
||||
foreach ($images as $image) {
|
||||
foreach ($image as $method => $uri) {
|
||||
$deal->$method($uri);
|
||||
|
Loading…
Reference in New Issue
Block a user