Page 1 of 2

how to read an web page by url.. using curl function.......

Posted: Thu Jun 21, 2007 4:39 pm
by djdon11
HI Friends......

well i have a issue of reading a web page by its url which [s]hv[/s] have same parameters to like http://www.blah.com?lang=EN...

this link is of the same web site from which its been used.......

i got a blank page after waiting a long time.......
i wrote a curl function code which reads the url of the other web sites & also gives the results but [s]wuth[/s] with the same website ,, its not working ... may [s]b[/s] be the url contains parameters thats why it is so......

i give the code here can anybody help me for this please.....

Code: Select all

$url = $HTTP_REFERER;

   $ch = curl_init();

   curl_setopt($ch, CURLOPT_URL,$url);
    
   curl_setopt($ch, CURLOPT_VERBOSE, 1);

   curl_setopt($ch, CURLOPT_POST, 0);

   curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);

   $returned = curl_exec($ch);

   curl_close ($ch);

   echo $returned;
[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1 wrote:11. Please use proper, complete spelling when posting in the forums. AOL Speak, leet speak and other abbreviated wording can confuse those that are trying to help you (or those that you are trying to help). Please keep in mind that there are many people from many countries that use our forums to read, post and learn. They do not always speak English as well as some of us, nor do they know these aberrant abbreviations. Therefore, use as few abbreviations as possible, especially when using such simple words.

Some examples of what not to do are ne1, any1 (anyone); u (you); ur (your or you're); 2 (to too); prolly (probably); afaik (as far as I know); etc.

Posted: Thu Jun 21, 2007 4:53 pm
by superdezign
I'm clueless.

Try using $_SERVER['HTTP_REFERER'] instead, see if it makes a difference.

how to read an web page by url.. using curl function.......

Posted: Thu Jun 21, 2007 6:58 pm
by djdon11
Sorry Friend..

It's not working :cry:

Posted: Thu Jun 21, 2007 7:56 pm
by superdezign
Echo out the referrer. If anything, it's just not being set (probably a server setting?).

Are you getting any errors?

how to read an web page by url.. using curl function.......

Posted: Thu Jun 21, 2007 8:10 pm
by djdon11
Hi Friend....

The refrer.. echo .the url of page which i want to read ... i.e. http://www.aurelis.org/session_of_the_w ... hp?lang=EN
which is the desire page i want to read......

well i m not getting any error bt the blank page ......

but if i use fopen then i got the message .. "connection timed out"

any gusses why all this happening

Posted: Thu Jun 21, 2007 8:20 pm
by superdezign
Maybe you're getting an infinite loop of the page including itself...?

HI again

Posted: Thu Jun 21, 2007 8:35 pm
by djdon11
But the other pages too are not opening of this site...

even the index page of the site is too not opening

Posted: Thu Jun 21, 2007 9:03 pm
by feyd
Maybe you're sending inappropriate messages for it to choose to return information.

Try specifying a valid, modern user-agent for example.

reading url with curl...

Posted: Sun Jun 24, 2007 1:57 pm
by djdon11
Sorry I did not got , what you want to say ........

can i have in detail please.. ?

Posted: Sun Jun 24, 2007 2:07 pm
by Benjamin
Your requesting the referrer?

Code: Select all

$HTTP_REFERER;

curl

Posted: Sun Jun 24, 2007 2:09 pm
by djdon11
Yes....

Posted: Sun Jun 24, 2007 2:11 pm
by Benjamin
Have you checked to see what the value of that is, and what is actually being requested?

curl..

Posted: Sun Jun 24, 2007 2:13 pm
by djdon11
Yes...
this refrer actually has the whole url of page which has to be read....

Posted: Sun Jun 24, 2007 2:23 pm
by Benjamin
Your code worked fine for me..

Code: Select all


$url = 'http://www.yahoo.com';

   $ch = curl_init();

   curl_setopt($ch, CURLOPT_URL,$url);
   
   curl_setopt($ch, CURLOPT_VERBOSE, 1);

   curl_setopt($ch, CURLOPT_POST, 0);

   curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);

   $returned = curl_exec($ch);

   curl_close ($ch);

   echo $returned;

curl

Posted: Sun Jun 24, 2007 2:27 pm
by djdon11
yups it is working fine for the url of another web sites with no any dynamic parameters..
but for the page of same website its not working .... & the page also have some parameters in url
.........
if we gave url of another website than its working fine but the url of the same website is not working