0

I am trying to parse a website where I have to first the cookies and then pass to another request. In Python I can do the following:

session = requests.Session()
response = session.get('https://www.page.com')
cookies = response.cookies
response = session.get('https://www.page.com/part/1234', headers=headers,cookies=cookies)
print(response.text)

What options do I have available if I use the file_get_contents or Requests library?

I could not find it in this library.

Volatil3
  • 14,253
  • 38
  • 134
  • 263
  • Examples for using cookies in PHP: https://www.w3schools.com/php/php_cookies.asp – Russ Jan 05 '21 at 14:23
  • 2
    See https://stackoverflow.com/questions/895786/how-to-get-the-cookies-from-a-php-curl-into-a-variable or similar questions – the_nuts Jan 05 '21 at 14:24
  • @the_nuts so curl is the only option? I thought some lib or `file_get_contents` can here here. – Volatil3 Jan 05 '21 at 14:30
  • file_get_contents returns only the body of the HTTP response, but the cookies are in the header – the_nuts Jan 05 '21 at 14:32
  • yeah there are a lot of libraries to perform http requests and handle them – the_nuts Jan 05 '21 at 14:36
  • @the_nuts Ok I did get how to capture cookies from a CURL request, how to exactly pass those captured cookies in another CURL request? should I save it in file or what? – Volatil3 Jan 06 '21 at 12:58
  • Sadly even capturing cookies not working. The site is ASP.NET and CURL is not capturing ASP Session cookies. – Volatil3 Jan 06 '21 at 14:25
  • You should understand how cookies work, the browser doesn't care what technology is behind the webserver, the cookies are just an instruction that he receives, and store... It will work for sure, now I can't write the code for you here... – the_nuts Jan 07 '21 at 16:09

0 Answers0