Using PHP to get the source code for the url, I have to log in to get

I am trying to write a PHP script that will get the source code of a page in my Amazon account. However, in order to get to this page, I have to log in. As far as I understand, I could do this by posting the correct request headers and then capturing the HTML response. It's right? If so, I would really appreciate it if someone could explain to me exactly how I would do it. If it is not, I would like to hear the right way to do it!

I used Firebug to get request and response headers. It is just a question of what to do with them now. I read elsewhere on this site that you cannot send a request using the PHP post method, and perhaps using cURL is the way to go. I really don't know anything about cURL, so the more information, the better.

Also, feel free to tell me some useful lessons on this topic.

Thank!

Max

+3
source share
1 answer

You probably need to log in using cURL first, get the cookies with the session ID, and then reuse these cookies in the next request to the page you need.

The way browsers work, sends cookies every time. You must imitate this.

+2
source

Source: https://habr.com/ru/post/1747388/


All Articles