php cURL problem
Posted: Tue Apr 06, 2010 4:38 pm
Hi,
I need to download a page source code to server and save it in the html file. First, I've tried to validate that page in http://validator.w3.org/ and got the answer "500 Internal Server Error"... later I've tried to download source code with fopen() function and it returned "failed to open stream: HTTP request failed! HTTP/1.1 500 Internal Server Error". The syntax was correct because that code worked with other URLs. Then I've tried to use cURL. The code is:
The result was a source code of only six lines when real source code of that page is much bigger. I can see that code using browser's "view source code" function. The first thought was that they are preventing connections from other servers or something.. or can it be that curl_init() function cant understand the given link? maybe because of the question mark? As you can see the URL of that page is https://pirkimai.eviesiejipirkimai.lt/a ... .asp?B=PPO. And also I've tested this code with other URLs ant it worked just fine. Any ideas? I woud appreciate any help. Thanks!
I need to download a page source code to server and save it in the html file. First, I've tried to validate that page in http://validator.w3.org/ and got the answer "500 Internal Server Error"... later I've tried to download source code with fopen() function and it returned "failed to open stream: HTTP request failed! HTTP/1.1 500 Internal Server Error". The syntax was correct because that code worked with other URLs. Then I've tried to use cURL. The code is:
Code: Select all
<?php
$ch = curl_init("https://pirkimai.eviesiejipirkimai.lt/app/notice/notices.asp?B=PPO");
$fp = fopen("./system/application/views/downloaded_html/home.html", "w");
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
fclose($fp);
echo "done";
?>