Run curl with the current Firefox cookies. This is useful for interacting with logged in websites from the shell, without having to manually deal with the login process.
The executable cookiefire
included in this package can be used to extract the cookies from Firefox.
This is achieved by reading the cookies.sqlite file in Firefox profiles.
This code is adapted from this Stack Exchange answer by hackerb9.
# Fetch google with the cookies from the default profile
curlfire https://www.google.com/
# Fetch google with the cookies from the blah profile
curlfire -P blah https://www.google.com/
# Getting cookies
cookiefire > /tmp/cookies
curl -b /tmp/cookies https://www.google.com/
- Does not work with session cookies(1) (you may be able to work around this by setting "Remember me" for the website with which you are using your tool)
- Only tested on linux machines
- Unlikely to work with windows
- Will probably work on macs but untested (feedback welcome)
cd ~
git clone https://github.com/talwrii/curlfire
echo 'PATH=$PATH:~/curlfire' >> ~/.bashrc
- Adapted from this Stack Exchange answer
- Firebug and friends allow one to copy requests as curl commands. This can be suitable for debugging.
- Cookies can be exported manually from within Firefox
All of these approaches can be time consuming when automating tasks.
Prior to Firefox 57, the remote control extension could be used to interact with the page currently viewed in Firefox from the shell (including outputting the current document object model as HTML).
Users of this project might also be interested in:
- clixpath (by author) - an open-source tool for extracting information out of HTML documents in machine-readable JSON using Xpath.
- PhantomJs - a scriptable command-line only browser than can be used to render the document object model in Javascript based-websites and output more easily processed HTML.
This code is distributed under an MIT license. It contains code adapted from a code snippet in the aforementioned Stack Exchange answer which is also distributed under an MIT license as stipulated by the Stack Exchange terms and conditions.