-
-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #60
- Loading branch information
Showing
7 changed files
with
97 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,3 +72,6 @@ dev = [ | |
"twine==3.4.2", | ||
"wheel==0.37.0", | ||
] | ||
|
||
[project.scripts] | ||
pycookiecheat = "pycookiecheat.__main__:main" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import argparse | ||
import json | ||
|
||
from .common import BrowserType, write_cookie_file | ||
from .chrome import chrome_cookies | ||
from .firefox import firefox_cookies | ||
|
||
|
||
def main(): | ||
parser = argparse.ArgumentParser( | ||
prog="pycookiecheat", | ||
description="Copy cookies from Chrome or Firefox and output as json", | ||
) | ||
parser.add_argument( | ||
"-u", "--url", required=True, help="requires scheme (e.g. `https://`)" | ||
) | ||
parser.add_argument("-b", "--browser", default="Chrome") | ||
parser.add_argument( | ||
"-o", | ||
"--output-file", | ||
help="Output to this file in netscape cookie file format", | ||
) | ||
args = parser.parse_args() | ||
|
||
# todo: make this a match statement once MSPV is 3.10 | ||
|
||
browser = BrowserType(args.browser) | ||
|
||
if browser == BrowserType.FIREFOX: | ||
cookie_func = firefox_cookies | ||
else: | ||
cookie_func = chrome_cookies | ||
|
||
cookies = cookie_func( | ||
url=args.url, | ||
browser=browser, | ||
) | ||
|
||
if args.output_file: | ||
write_cookie_file(args.output_file, cookies) | ||
else: | ||
print(json.dumps(cookies, indent=4)) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters