Curl facebook Post?

  • Autor Autor Henry00jj95
  • Fecha de inicio Fecha de inicio
Henry00jj95

Henry00jj95

Zeta
Verificado
Verificación en dos pasos activada
Verificado por Whatsapp
¡Ha verificado su Paypal!
Verificado por Binance
Hola betas alguien tienes CURL para scrapear un post de facebook.

PHP:
$headers = array(
    "authority: www.facebook.com",
    "cache-control: max-age=0",
    "upgrade-insecure-requests: 1",
    "user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36",
    "accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
    "sec-gpc: 1",
    "sec-fetch-site: same-origin",
    "sec-fetch-mode: navigate",
    "sec-fetch-user: ?1",
    "sec-fetch-dest: document",
    "accept-language: es-ES,es;q=0.9",
);

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, 'https://www.facebook.com/groups/xxxxxxxxxxxxxx/posts/xxxxxxxxxxxxxx/');
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_ENCODING, '');
curl_setopt($ch, CURLOPT_TIMEOUT, 20);

$result = curl_exec($ch);

he intentado con este codigo pero me tira error o me sale la web en blanco?
alguien por aqui lo trabaja a facebook?

o toca trabajarle con el api directamente?
 
1646304890096.png

Esta bien que obtengas una pagina en blanco, porque como se ve facebook crea la pagina con javascript.

Si queres seguir con curl, solo te quedaría hacer regex's de los valores/nombres importantes
Insertar CODE, HTML o PHP:
(?<="text": ).*(?=")
... etc
 
Henry00jj95 dijo:
Pero haz logrado sacarlo en json tal cual me mandas el ejemplo, ami por decir no me sale con los json....
Ver el archivo adjunto 705600
Ahí probé con php y con esto si me funciona:
PHP:
<?php
function facebook_view($url)
{
    $headers   = array();
    $headers[] = 'Host: www.facebook.com';
    $headers[] = 'Connection: keep-alive';
    $headers[] = 'Cache-Control: max-age=0';
    $headers[] = 'viewport-width: 1745';
    $headers[] = 'sec-ch-ua: " Not A;Brand";v="99", "Chromium";v="98", "Opera";v="84"';
    $headers[] = 'sec-ch-ua-mobile: ?0';
    $headers[] = 'sec-ch-ua-platform: "Windows"';
    $headers[] = 'sec-ch-prefers-color-scheme: dark';
    $headers[] = 'Upgrade-Insecure-Requests: 1';
    $headers[] = 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36';
    $headers[] = 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9';
    $headers[] = 'Sec-Fetch-Site: same-origin';
    $headers[] = 'Sec-Fetch-Mode: navigate';
    $headers[] = 'Sec-Fetch-User: ?1';
    $headers[] = 'Sec-Fetch-Dest: document';
    $headers[] = 'Accept-Encoding: gzip';
    $headers[] = 'Accept-Language: es-419,es;q=0.9,en-US;q=0.8,en;q=0.7';
    curl_setopt_array(
        $ch = curl_init(),
        array(
            CURLOPT_RETURNTRANSFER => 1,
            // CURLOPT_IPRESOLVE      => CURL_IPRESOLVE_V4,
            CURLOPT_FOLLOWLOCATION => false,
            CURLOPT_SSL_VERIFYPEER => false,
            CURLOPT_SSL_VERIFYHOST => 2,
            CURLOPT_HEADER         => false,
            CURLOPT_HTTPHEADER     => $headers,
            CURLOPT_TIMEOUT        => 50,
            CURLOPT_CONNECTTIMEOUT => 50,
            CURLOPT_ENCODING => "gzip"
        )
    );
    curl_setopt($ch, CURLOPT_URL, $url);
    $response = curl_exec($ch);
    return $response;
}
echo facebook_view('https://www.facebook.com/groups/1340336173135447/permalink/1340338796468518/');
 

Temas similares

Atrás
Arriba