phantomjs
---
Ладно, помогу тебе, а то будешь всю жизнь ajax парсить регулярками :)
1. Создай пустую папку ali
2. Скачай туда композер
https://getcomposer.org/composer.phar
3. Cоздай файл composer.json с таким содержимым
{
"require": {
"jonnyw/php-phantomjs": "3.*",
"symfony/dom-crawler": "3.*",
"symfony/css-selector": "3.*"
},
"config": {
"bin-dir": "bin"
},
"scripts": {
"post-install-cmd": [
"PhantomInstaller\\Installer::installPhantomJS"
],
"post-update-cmd": [
"PhantomInstaller\\Installer::installPhantomJS"
]
}
}
4. Выполни
php composer.phar install
5. Создай файл index.php
<?php
require __DIR__ . '/vendor/autoload.php';
$client = \JonnyW\PhantomJs\Client::getInstance();
$request = $client->getMessageFactory()->createRequest('http://superdeals.aliexpress.com/en?spm=2114.11010108.21.1.v65LIL', 'GET');
$response = $client->getMessageFactory()->createResponse();
$client->send($request, $response);
$html = $response->getContent();
$crawler = new \Symfony\Component\DomCrawler\Crawler($html);
$div = $crawler->filter('div.pro-msg');
if($div) {
echo $div->first()->text();
}
6. Выполни его php index.php и смотри результат
/usr/local/bin/php /Users/evgenij/projects/untitled/index.php
Today Only
Boy's Coat
> Synthetic leather> Motor jacket style> Available in black and red
share:
vk
pinterest
facebook
Twinner
Google+
Email
Sign in and share the website for a chance to get Points, which you can then convert to coupons.
US $9.74
US $32.48 / piece | 70% Off
0486Left
Buy Now
Process finished with exit code 0