Jump to content

Recommended Posts

Hi,

I'm having trouble parsing multiple pages in a curl session..

 

I am using curl to parse a page that requires a cookie, I can do that fine and store the information that I need using

$result=curl_exec($ch);

 

and then parsing $result

 

after doing that, I want to go to another page and parse that one, I change the variable $url and then use

 

curl_setopt($ch, CURLOPT_URL,$url); 

$result=curl_exec($ch);

 

but $result is the same page as the first one :-(

 

why am I getting the same contents for $result?

 

hope you can help

 

Andy

Link to comment
https://forums.phpfreaks.com/topic/54046-parse-multiple-pages-with-curl-session/
Share on other sites

thanks for responding chigley, seeing as you said it should work I went through the code a bit more and found out why I was getting the same page, coz I'm stupid!!

 

I was putting $result into $rows by using explode() and parsing $rows to find the info, after the next curl_exec() I forgot to put the $result into $rows again so I was parsing the same array again and again, the $result was actually updating.

 

It took me all morning to write a new script that can take my login details and then store the cookie  after sending them to the login page and then going on to the prospects page, so I learned how to do that at least!! thats when I saw your message and looked back at my original code and found out what was wrong. doh!

 

I'm using curl_setopt($ch, CURLOPT_COOKIE, 'cookiefrom livehttp headers'); after logging in to the site and copying the cookie contents from live http headers plugin and pasting it into the code which works as long I don't wait too long to run the script.

 

on my new script, I tried to parse the login page of the site to get the captcha image and display it on a form and then when the form is submitted, pass the captcha details to the script that will then try and log in with a set username and password but I'm having problems with the captcha image, I can get it and display it but when the form is processed, it comes up with "wrong code number" which is probably because I parse the page and then call the image again so it would have changed. hmmmm, need to figure that out!

 

thanks for answering

 

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.