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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

djdon11
Forum Commoner
Posts: 90
Joined: Wed Jun 20, 2007 5:03 pm

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

Post 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.
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

I'm clueless.

Try using $_SERVER['HTTP_REFERER'] instead, see if it makes a difference.
djdon11
Forum Commoner
Posts: 90
Joined: Wed Jun 20, 2007 5:03 pm

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

Post by djdon11 »

Sorry Friend..

It's not working :cry:
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

Echo out the referrer. If anything, it's just not being set (probably a server setting?).

Are you getting any errors?
djdon11
Forum Commoner
Posts: 90
Joined: Wed Jun 20, 2007 5:03 pm

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

Post 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
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

Maybe you're getting an infinite loop of the page including itself...?
djdon11
Forum Commoner
Posts: 90
Joined: Wed Jun 20, 2007 5:03 pm

HI again

Post by djdon11 »

But the other pages too are not opening of this site...

even the index page of the site is too not opening
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Maybe you're sending inappropriate messages for it to choose to return information.

Try specifying a valid, modern user-agent for example.
djdon11
Forum Commoner
Posts: 90
Joined: Wed Jun 20, 2007 5:03 pm

reading url with curl...

Post by djdon11 »

Sorry I did not got , what you want to say ........

can i have in detail please.. ?
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

Your requesting the referrer?

Code: Select all

$HTTP_REFERER;
djdon11
Forum Commoner
Posts: 90
Joined: Wed Jun 20, 2007 5:03 pm

curl

Post by djdon11 »

Yes....
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

Have you checked to see what the value of that is, and what is actually being requested?
djdon11
Forum Commoner
Posts: 90
Joined: Wed Jun 20, 2007 5:03 pm

curl..

Post by djdon11 »

Yes...
this refrer actually has the whole url of page which has to be read....
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post 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;
djdon11
Forum Commoner
Posts: 90
Joined: Wed Jun 20, 2007 5:03 pm

curl

Post 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
Post Reply