How to get session id and do login web form with session id curl?
How to 开发者_如何学编程get session id and do login web form with session id curl?
Set CURLOPT_RETURNTRANSFER, store the return value of curl_exec()
in a variable, use string functions and/or regular expressions to extract the session id from the page.
If the session ID is just in a header (e.g. Set-cookie), use curl_setopt()
to set CURLOPT_HEADER
so headers are included in the output.
If you want to use the session id later to submit a form, set CURLOPT_POST
to true and CURLOPT_POSTFIELDS
to an associative array containing your POST data.
Useful php documentation links:
- http://php.net/curl_exec
- http://php.net/curl_setopt
- http://php.net/preg_match
精彩评论