DokuWiki

It's better when it's simple

User Tools

Site Tools


tips:curl_login

Logging in with cURL

Sometimes you might want to monitor or grab pages directly from scripts. It is easy, unless your DokuWiki installation requires logging in. In that case you can use cookie and POST variable support in curl.

Step 1 - log in and store cookie.

curl -d "u=<username>&p=<password>" --cookie-jar cjar http://www.my.wiki/path/?do=login

This stores login cookie in a file named cjar in the current directory. Now we can retrieve pages that require us to be logged in.

Step 2 - retrieve pages.

Now we can easily retrieve protected pages, but we still have to indicate to DokuWiki that we are the same person who logged in previously.

curl --cookie cjar --cookie-jar cjar http://www.my.wiki/path/that/requires/login

This reuses cookie from the cjar file and allows us to retrieve those pages.

See also

tips/curl_login.txt · Last modified: 2019-06-07 09:10 by Michaelsy

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki