Help me to complete my challenge PHP Help NEEDED

MgicalaEarner

Elite Member
Joined
Jul 8, 2017
Messages
3,749
Reaction score
4,861
So basically i have got a challenge from my friend , i have some basics knowledge.
So challenge is i the codes need to fetch Title and description from youtube.
I am using Curl for this , so far this is what i have done
header('content-type:text/plain');
$curl = curl_init();
curl_setopt($curl , CURLOPT_URL , "https://www.youtube.com/results?search_query=curl+php+scrape+title");
curl_setopt($curl , CURLOPT_SSL_VERIFYPEER , FALSE);
curl_setopt($curl , CURLOPT_RETURNTRANSFER , 1); #always use 1 instead of url else it won't work
$result = curl_exec($curl);
$re = ""title":{"runs":[{"text":"(.*?)"}]";
preg_match_all($re, $result, $result, PREG_SET_ORDER, 0);

print_r ($result);
If you check this code $re = ""title":{"runs":[{"text":"(.*?)"}]";
this is where i think i am doing wrong and idk what is the correct regex i use, any help will be much much appreciated.
Thanks
 
Last edited:
You can’t have double quote within double quote. You have to escape the inner one. E.g. “\”something\””. That’s not a valid regex though lol. Try regex101.com for learning more about it.
 
You can’t have double quote within double quote. You have to escape the inner one. E.g. “\”something\””. That’s not a valid regex though lol. Try regex101.com for learning more about it.
Ya i know its not correct i am totally too new in php and regex. CHeck PM
 
Back
Top