Using PHP to get the source code of a URL I must be logged in to reach
I am trying to write a PHP script that will get the source code of a page in my Amazon account. However, to reach that page, I must be logged in. From what I understand, I should be able to accomplish this by posting the correct request headers, and then capturing the HTML response. Is that correct? If so, I'd really appreciate it if someone could explain to me how exactly I would do this. If it's not right, I'd love to hear the correct way of doing it!
I've used Firebug to get the request and response headers I need. It's just a matter of what to do with them now. I read elsewhere on this site that you can't send a request with the PHP post method, and that perhaps using cURL is the way to go. I really know nothing about cU开发者_如何学JAVARL, so the more info the better.
Also, feel free to point me to some useful tutorials on this topic.
Thanks!
Max
You'll probably need to log in first using cURL, get the cookies with the session ID, then re-use those cookies in the following request to the actual page you need.
That's how browsers work, re-sending cookies every time. You should mimic that.
精彩评论