curl not working for getting a web page content, why?

Thread Solved

Join Date: Sep 2008
Posts: 33
Reputation: jyotiu is an unknown quantity at this point 
Solved Threads: 0
jyotiu jyotiu is offline Offline
Light Poster

curl not working for getting a web page content, why?

 
0
  #1
May 2nd, 2009
Hi all
i am using a curl script to go to a link and get its content for further manipulation. following is the link and curl script:
  1. <?php
  2. $url = 'http://criminaljustice.state.ny.us/cgi/internet/nsor/fortecgi?serviceName=WebNSOR&amp;templateName=detail.htm&amp;requestingHandler=WebNSORDetailHandler&amp;ID=368343543';
  3.  
  4. //curl script to get content of given url
  5. $ch = curl_init();
  6. // set the target url
  7. curl_setopt($ch, CURLOPT_URL,$url);
  8. // request as if Firefox
  9. curl_setopt($ch, CURLOPT_HTTPHEADER, Array("User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.15) Gecko/20080623 Firefox/2.0.0.15") );
  10. curl_setopt($ch, CURLOPT_NOBODY, false);
  11. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  12. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  13. $result= curl_exec ($ch);
  14. curl_close ($ch);
  15. echo $result;
  16. ?>

but the website is not excepting it through script it is giving user exception in result, but if we normally paste the url in browser it is opening the page perfectly alright.

Please help, what i am doing wrong here.

Thanks and regards
jyotiu
Last edited by jyotiu; May 2nd, 2009 at 1:29 am.
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 33
Reputation: jyotiu is an unknown quantity at this point 
Solved Threads: 0
jyotiu jyotiu is offline Offline
Light Poster

Re: curl not working for getting a web page content, why?

 
0
  #2
May 2nd, 2009
I got what the problem was in the url there is &amp; instead of & symbol that is creating a problem
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Other Threads in the PHP Forum
Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC