skip to Main Content

PHP cURL: How to resolve the "connection timeout" error while scraping data from a particular website?

I am trying to scrape the h1 element from the HTML body of a particular website: <?php error_reporting(E_ALL); ini_set('display_errors', 1); header('Content-Type: text/plain; charset=utf-8'); header('Access-Control-Allow-Origin: *'); header('Access-Control-Allow-Methods: POST, GET, OPTIONS'); if(isset($_POST["url"])){ $user_agent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_4) AppleWebKit/537.36…

VIEW QUESTION

CURL command as a PHP script

I am trying to convert this CURL command: curl -i https://myurl >toto.txt into a PHP script, but it doesn't work. $ch_rech = curl_init(); curl_setopt($ch_rech, CURLOPT_URL, "https://myurl"); curl_setopt($ch_rech, CURLOPT_HEADER, 0); ob_start(); curl_exec($ch_rech); curl_close($ch_rech); $Results = ob_get_contents(); ob_end_clean(); How can I do…

VIEW QUESTION
Back To Top
Search