Can't read page content anymore

ToBad

New member
Hello!
Long time I parse page http://cetatenie.just.ro/ordine-articolul-11/ with Curl but after some changes on server I can't read it anymore.
Can you show me any PHP code what can sucessfuly read this page?
Thank you!
 
Certainly! Here's an example PHP code that uses cURL to read the contents of a web page:
<?php
// Create a cURL handle
$ch = curl_init();

// Set the URL to fetch
curl_setopt($ch, CURLOPT_URL, 'http://cetatenie.just.ro/ordine-articolul-11/');

// Set the option to return the transfer as a string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

// Execute the request
$response = curl_exec($ch);

// Check for errors
if (curl_errno($ch)) {
echo 'Error reading the page: ' . curl_error($ch);
exit;
}

// Close the cURL handle
curl_close($ch);

// Print the page content
echo $response;
?>


Certainly! Here's an example PHP code that uses cURL to read the contents of a web page:

phpCopy code
<?php
// Create a cURL handle
$ch = curl_init();

// Set the URL to fetch
curl_setopt($ch, CURLOPT_URL, 'http://cetatenie.just.ro/ordine-articolul-11/');

// Set the option to return the transfer as a string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

// Execute the request
$response = curl_exec($ch);

// Check for errors
if (curl_errno($ch)) {
echo 'Error reading the page: ' . curl_error($ch);
exit;
}

// Close the cURL handle
curl_close($ch);

// Print the page content
echo $response;
?>

This code initializes a cURL handle, sets the URL to fetch (http://cetatenie.just.ro/ordine-articolul-11/ in this case), and sets the CURLOPT_RETURNTRANSFER option to 1, which tells cURL to return the transfer as a string instead of outputting it directly.

After executing the request with curl_exec(), you can check for any errors using curl_errno() and print the page content using echo $response.

Please note that if the server has implemented any security measures or rate limiting, you might need to handle additional headers or parameters in your cURL request. However, the provided code should work for basic web page retrieval.
 
Back
Top