file_get_contents from url that is only accessible after log-in to website

前端 未结 2 1275
失恋的感觉
失恋的感觉 2020-12-09 05:55

I would like to make a php script that can capture a page from a website. Think file_get_contents($url).

However, this website requires that you fill in a u

2条回答
  •  无人及你
    2020-12-09 06:29

    The http pecl extension can do it, also PEAR::HTTP_Client, Snoopy and many many other libraries/classes. If you (for whatever reason) you want to achieved this with file_get_contents, you can use the stream context options for the http wrapper to set POST and cookie parameters and stream_get_meta_data to read the response headers including the cookies.

提交回复
热议问题