Помогите пожалуйста подправить скрипт, что бы он умел заполнять поле «Цена» и сохранять лот.
Вид поля "цена" на аукро выполняется таким кодом:
<input type="text" size="10" maxlength="12" name="buyNowPrice" id="buyNowPrice" data-payu-maximum="20000" value="5000"/>
Пробовал передать значение в функцию:
function getContent("http://aukro.ua//NewItem/Index.php/restore/prev_item_id,$id_lot", buyNowPrice= 'цена '), первый параметр это страница редактирования лотов, второй это как я «пытаюсь передать цену» для дальнейшего POSTFIELDS к странице. Но никак не получается передать цену, цена показывается такая что и была. Так же не получается с сохранением лота, то есть с отправкой формы с лотом.
Сама кнопка с лотом отображается кодом:
<input type="submit" class="marginLeft5 form-submit right" value="Далее >"/>
При нажатии обработчик: http://aukro.ua/NewItem/Preview.php
Выкладываю исходники, того что уже есть, может кому понадобиться. Любые советам по доработке буду очень рад.
]$login = array(
'name' => 'LOGIN', // E-mail или логин
'pass' => 'PASSWORD' // пароль
);
// "пытаемся" зайти в кабинет
$content = getContent('http://aukro.ua/myaccount/');
// после многочисленных редиректов через Location, получаем нужную страницу с нужными переменными
preg_match_all('~<input\b(?:(?=(\s+(?:name="([^"]*)"|value="([^"]*)")|[^\s>]+|\s+))\1)*>~ism', $content, $inputs, PREG_SET_ORDER);
$post = '';
for ($i = 0, $c = sizeof($inputs); $i < $c; ++$i) {
$input = $inputs[$i];
if (empty($input[2])) {
continue;
}
if ($input[2] == 'userForm[login]') {
$input[3] = $login['name'];
} elseif ($input[2] == 'userForm[password]') {
$input[3] = $login['pass'];
} else {
$input[3] = isset($input[3]) ? html_entity_decode($input[3]) : '';
}
$post .= urlencode($input[2]) . '=' . urlencode($input[3]) . '&';
}
// пытаемся залогинится, тут опять многочисленные редиректы через Location
$content = getContent('https://ssl.aukro.ua/fnd/authentication/', $post);
// если авторизация прошла успешно, то сайт в этот раз делает редирект через meta
preg_match("#<meta[^>]+URL=(.*)\">#iU", $content, $url);
if (!empty($url[1])) {
// можно пройтись по этой ссылке из meta
// $content = getContent($url[1]);
// переходим на страницу лотов (страницу "показать все лоты на одной странице)
$content = getContent('http://aukro.ua/myaccount/sell.php/showAll,1');
/* Получаем id лота из страницы всех лотов */
preg_match_all('/ДЕШЕВЛЕ НЕТ! Эксклюзивные женские ботфорты<.span><.a>.<span.class=.smaller.>\(?\'?([^"\<\)]+)/i', $content, $id_lot, PREG_SET_ORDER);
foreach ($id_lot as $id_lot)
{
$id_lot = $id_lot[1];
echo $id_lot; // отображаем ссылку на лот
echo '<br/>';
}
/* Получаем id лота */
$link_for_lot = 'http://aukro.ua/show_item.php?item='."$id_lot"; // Формируем сылку на лот
echo $link_for_lot; // Отображаем сылку
$content = getContent("$link_for_lot"); // Отображаем лот
$content = getContent("http://aukro.ua/item_change.php?item_id=$id_lot&"); // Переходим на страницу где есть кнопки "Завершить и изменить лот"
$content = getContent("http://aukro.ua//NewItem/Index.php/restore/prev_item_id,$id_lot", '', 'buyNowPrice=900' ); // Переходим на страницу изменение и пробуем заполнить поле цена
// выводим содержимое на екран
echo $content;
}
function getContent($url, $postfields = ' ')
{
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_USERAGENT, 'Opera/9.80 (Windows NT 6.2; WOW64) Presto/2.12.388 Version/12.16');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 'false');
curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie_aukro.txt');
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie_aukro.txt');
if (!empty($postfields)) {
curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
curl_setopt($ch, CURLOPT_POST, 1);
}
$content = curl_exec($ch);
curl_close($ch);
return $content;