Jump to content
deserty

functie CURL

Recommended Posts

Posted

Am urmatorul cod :


<?php
function ia_continutul($url) {
$ch = curl_init();
$timeout = 5;
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}


$pagina = "https://rstcenter.com";
$continut= ia_continutul($pagina);

echo $continut;

?>

Cum pot pune intr-o variabila doar o bucata cod din ceea ce imi returneaza $continut ?

exemplu : $var="[RST]";

Posted (edited)

strpos, substr, preg_match, preg_match_all, etc.

regexpal.com

Iti recomand insa Guzzle ca si crawler (pentru ca suporta caching si requesturi paralele) si componenta symfony CssSelector pentru parsare de DOM. Poti sa le combini usor cu composer.

Edited by Irk
Posted

Merci. Am sa le studiez, insa mai simplu nu se poate ?

Vreau sa extrag doar o bucata de cod din ceea ce imi returneaza.

Am cautat niste parametrii pentru curl_exec, insa nu am gasit.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...