-
Anonymous
Авторизация PHP Curl и анализ таблицы продуктов по другой ссылке (я снова получаю страницу входа)
Сообщение
Anonymous »
Код: Выделить всё
$ch = curl_init();
$post_field = 'ajax=SearchArticulo&cntrSgn=DeExMEkRabGEO396gOLDMqUZiXe2BibRjqgUXwZlQmMgrw4jJmdAwbUD11%2BddBhn&srcInicio=false&isSimple=false&codMarca=0&field=nombre&value=&oferta=false&pvpSubido=False&detallada=false&codPedido=';
$post_field .= '&cat1=5&cat2=87&cat3=314&token=';
curl_setopt($ch, CURLOPT_URL, 'https://actibios.com/WebForms/Clientes/GenerarPedidosVentas_new.aspx');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_field);
$headers = array();
$headers[] = 'Accept: */*';
$headers[] = 'Accept-Language: ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7';
$headers[] = 'Cache-Control: no-cache';
$headers[] = 'Connection: keep-alive';
$headers[] = 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8';
$headers[] = 'Cookie: grpAct@Session=sessionhere; grpAct@CodEmpresa=1; grpAct@CodDelegacion=1; grpAct@Year=; grpAct@Version=2024.01.25.005; SERVERUSED=srv2|ZicBV|ZicBR';
$headers[] = 'Dnt: 1';
$headers[] = 'Origin: https://actibios.com';
$headers[] = 'Pragma: no-cache';
$headers[] = 'Referer: https://actibios.com/WebForms/Clientes/GenerarPedidosVentas_new.aspx';
$headers[] = 'Sec-Fetch-Dest: empty';
$headers[] = 'Sec-Fetch-Mode: cors';
$headers[] = 'Sec-Fetch-Site: same-origin';
$headers[] = 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36';
$headers[] = 'X-Requested-With: XMLHttpRequest';
$headers[] = 'Sec-Ch-Ua: \"Google Chrome\";v=\"123\", \"Not:A-Brand\";v=\"8\", \"Chromium\";v=\"123\"';
$headers[] = 'Sec-Ch-Ua-Mobile: ?0';
$headers[] = 'Sec-Ch-Ua-Platform: \"Windows\"';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close($ch);
$dom = new DOMDocument();
$dom->loadHTML($result);
$tables = $dom->getElementsByTagName('table');
$table_array = array();
foreach ($tables as $table) {
$rows = $table->getElementsByTagName('tr');
foreach ($rows as $row) {
$cols = $row->getElementsByTagName('td');
$row_array = array();
foreach ($cols as $col) {
$row_array[] = $col->nodeValue;
}
$table_array[] = $row_array;
}
}
foreach ($table_array as &$item) {
// get description
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'https://actibios.com/WebForms/Clientes/Indicacion.aspx?cp='.$item[0]);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, "ajax=GetIndicacion&codArticulo=".$item[0]);
$header = array();
$header[] = 'Accept: image/avif,image/webp,image/apng,image/svg+xml,image/*,*/*;q=0.8';
$header[] = 'Accept-Language: ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7';
$header[] = 'Cache-Control: no-cache';
$header[] = 'Connection: keep-alive';
$header[] = 'Cookie: grpAct@CodEmpresa=1; grpAct@CodDelegacion=1; grpAct@Year=; grpAct@Version=2024.01.25.005; ASP.NET_SessionId=l11hf41gpuxnha32puvxnvn4; grpAct@Session=sessionhere; SERVERUSED=srv1|ZiYu5|ZiYu2';
$header[] = 'Dnt: 1';
$header[] = 'Pragma: no-cache';
$header[] = 'Referer: https://actibios.com/WebForms/Clientes/Indicacion.aspx?cp='.$item[0];
$header[] = 'Sec-Fetch-Dest: image';
$header[] = 'Sec-Fetch-Mode: no-cors';
$header[] = 'Sec-Fetch-Site: same-origin';
$header[] = 'Sec-Fetch-User: ?1';
$header[] = 'Upgrade-Insecure-Requests: 1';
$header[] = 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36';
$header[] = 'Sec-Ch-Ua: \"Google Chrome\";v=\"123\", \"Not:A-Brand\";v=\"8\", \"Chromium\";v=\"123\"';
$header[] = 'Sec-Ch-Ua-Mobile: ?0';
$header[] = 'Sec-Ch-Ua-Platform: \"Windows\"';
$header[] = 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8';
$header[] = 'Origin: https://actibios.com';
$header[] = 'X-Requested-With: XMLHttpRequest';
curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
$Indicacion = curl_exec($curl);
if (curl_errno($curl)) {
echo 'Error:' . curl_error($curl);
}
curl_close($curl);
$page_content = preg_replace('/
Подробнее здесь: [url]https://stackoverflow.com/questions/78391024/php-curl-authorization-and-parse-product-table-from-another-link-i-get-login-pa[/url]
1714143905
Anonymous
[code]$ch = curl_init();
$post_field = 'ajax=SearchArticulo&cntrSgn=DeExMEkRabGEO396gOLDMqUZiXe2BibRjqgUXwZlQmMgrw4jJmdAwbUD11%2BddBhn&srcInicio=false&isSimple=false&codMarca=0&field=nombre&value=&oferta=false&pvpSubido=False&detallada=false&codPedido=';
$post_field .= '&cat1=5&cat2=87&cat3=314&token=';
curl_setopt($ch, CURLOPT_URL, 'https://actibios.com/WebForms/Clientes/GenerarPedidosVentas_new.aspx');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_field);
$headers = array();
$headers[] = 'Accept: */*';
$headers[] = 'Accept-Language: ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7';
$headers[] = 'Cache-Control: no-cache';
$headers[] = 'Connection: keep-alive';
$headers[] = 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8';
$headers[] = 'Cookie: grpAct@Session=sessionhere; grpAct@CodEmpresa=1; grpAct@CodDelegacion=1; grpAct@Year=; grpAct@Version=2024.01.25.005; SERVERUSED=srv2|ZicBV|ZicBR';
$headers[] = 'Dnt: 1';
$headers[] = 'Origin: https://actibios.com';
$headers[] = 'Pragma: no-cache';
$headers[] = 'Referer: https://actibios.com/WebForms/Clientes/GenerarPedidosVentas_new.aspx';
$headers[] = 'Sec-Fetch-Dest: empty';
$headers[] = 'Sec-Fetch-Mode: cors';
$headers[] = 'Sec-Fetch-Site: same-origin';
$headers[] = 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36';
$headers[] = 'X-Requested-With: XMLHttpRequest';
$headers[] = 'Sec-Ch-Ua: \"Google Chrome\";v=\"123\", \"Not:A-Brand\";v=\"8\", \"Chromium\";v=\"123\"';
$headers[] = 'Sec-Ch-Ua-Mobile: ?0';
$headers[] = 'Sec-Ch-Ua-Platform: \"Windows\"';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close($ch);
$dom = new DOMDocument();
$dom->loadHTML($result);
$tables = $dom->getElementsByTagName('table');
$table_array = array();
foreach ($tables as $table) {
$rows = $table->getElementsByTagName('tr');
foreach ($rows as $row) {
$cols = $row->getElementsByTagName('td');
$row_array = array();
foreach ($cols as $col) {
$row_array[] = $col->nodeValue;
}
$table_array[] = $row_array;
}
}
foreach ($table_array as &$item) {
// get description
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'https://actibios.com/WebForms/Clientes/Indicacion.aspx?cp='.$item[0]);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, "ajax=GetIndicacion&codArticulo=".$item[0]);
$header = array();
$header[] = 'Accept: image/avif,image/webp,image/apng,image/svg+xml,image/*,*/*;q=0.8';
$header[] = 'Accept-Language: ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7';
$header[] = 'Cache-Control: no-cache';
$header[] = 'Connection: keep-alive';
$header[] = 'Cookie: grpAct@CodEmpresa=1; grpAct@CodDelegacion=1; grpAct@Year=; grpAct@Version=2024.01.25.005; ASP.NET_SessionId=l11hf41gpuxnha32puvxnvn4; grpAct@Session=sessionhere; SERVERUSED=srv1|ZiYu5|ZiYu2';
$header[] = 'Dnt: 1';
$header[] = 'Pragma: no-cache';
$header[] = 'Referer: https://actibios.com/WebForms/Clientes/Indicacion.aspx?cp='.$item[0];
$header[] = 'Sec-Fetch-Dest: image';
$header[] = 'Sec-Fetch-Mode: no-cors';
$header[] = 'Sec-Fetch-Site: same-origin';
$header[] = 'Sec-Fetch-User: ?1';
$header[] = 'Upgrade-Insecure-Requests: 1';
$header[] = 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36';
$header[] = 'Sec-Ch-Ua: \"Google Chrome\";v=\"123\", \"Not:A-Brand\";v=\"8\", \"Chromium\";v=\"123\"';
$header[] = 'Sec-Ch-Ua-Mobile: ?0';
$header[] = 'Sec-Ch-Ua-Platform: \"Windows\"';
$header[] = 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8';
$header[] = 'Origin: https://actibios.com';
$header[] = 'X-Requested-With: XMLHttpRequest';
curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
$Indicacion = curl_exec($curl);
if (curl_errno($curl)) {
echo 'Error:' . curl_error($curl);
}
curl_close($curl);
$page_content = preg_replace('/
Подробнее здесь: [url]https://stackoverflow.com/questions/78391024/php-curl-authorization-and-parse-product-table-from-another-link-i-get-login-pa[/url]