add '--cookies' command-line option
This commit is contained in:
parent
58e95a7487
commit
a804a42e23
@ -15,6 +15,7 @@ import queue
|
||||
import logging
|
||||
import requests
|
||||
import threading
|
||||
import http.cookiejar
|
||||
from .message import Message
|
||||
from .. import config
|
||||
|
||||
@ -30,6 +31,15 @@ class Extractor():
|
||||
self.session = requests.Session()
|
||||
self.log = logging.getLogger(self.category)
|
||||
|
||||
cookies = self.config("cookies")
|
||||
if cookies:
|
||||
try:
|
||||
cj = http.cookiejar.MozillaCookieJar()
|
||||
cj.load(cookies)
|
||||
self.session.cookies = cj
|
||||
except OSError as exc:
|
||||
self.log.warning("cookies: %s", exc)
|
||||
|
||||
def __iter__(self):
|
||||
return self.items()
|
||||
|
||||
|
@ -125,6 +125,11 @@ def build_parser():
|
||||
metavar="SECONDS", action=ConfigAction, dest="timeout", type=float,
|
||||
help="Timeout for HTTP connections (defaut: no timeout)",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--cookies",
|
||||
metavar="FILE", action=ConfigAction, dest="cookies",
|
||||
help="File to load additional cookies from",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-c", "--config",
|
||||
metavar="CFG", dest="cfgfiles", action="append",
|
||||
|
Loading…
x
Reference in New Issue
Block a user