| skipped 52 lines |
53 | 53 | | |
54 | 54 | | unsupported_characters = '#' |
55 | 55 | | |
56 | | - | cookies_file = 'cookies.txt' |
57 | | - | |
58 | | - | |
59 | 56 | | async def get_response(request_future, site_name, logger): |
60 | 57 | | html_text = None |
61 | 58 | | status_code = 0 |
| skipped 248 lines |
310 | 307 | | async def maigret(username, site_dict, query_notify, logger, |
311 | 308 | | proxy=None, timeout=None, recursive_search=False, |
312 | 309 | | id_type='username', debug=False, forced=False, |
313 | | - | max_connections=100, no_progressbar=False): |
| 310 | + | max_connections=100, no_progressbar=False, |
| 311 | + | cookies=None): |
314 | 312 | | """Main search func |
315 | 313 | | |
316 | 314 | | Checks for existence of username on various social media sites. |
| skipped 31 lines |
348 | 346 | | connector = ProxyConnector.from_url(proxy) if proxy else aiohttp.TCPConnector(ssl=False) |
349 | 347 | | # connector = aiohttp.TCPConnector(ssl=False) |
350 | 348 | | connector.verify_ssl=False |
351 | | - | session = aiohttp.ClientSession(connector=connector, trust_env=True) |
| 349 | + | |
| 350 | + | cookies_dict = {} |
| 351 | + | if cookies: |
| 352 | + | cookies_obj = cookielib.MozillaCookieJar(cookies) |
| 353 | + | cookies_obj.load(ignore_discard=True, ignore_expires=True) |
| 354 | + | |
| 355 | + | for c in cookies_obj: |
| 356 | + | cookies_dict[c.name] = c.value |
| 357 | + | |
| 358 | + | session = aiohttp.ClientSession(connector=connector, trust_env=True, cookies=cookies_dict) |
352 | 359 | | |
353 | 360 | | if logger.level == logging.DEBUG: |
354 | 361 | | future = session.get(url='https://icanhazip.com') |
| skipped 91 lines |
446 | 453 | | # The final result of the request will be what is available. |
447 | 454 | | allow_redirects = True |
448 | 455 | | |
449 | | - | # TODO: cookies using |
450 | | - | # def parse_cookies(cookies_str): |
451 | | - | # cookies = SimpleCookie() |
452 | | - | # cookies.load(cookies_str) |
453 | | - | # return {key: morsel.value for key, morsel in cookies.items()} |
454 | | - | # |
455 | | - | # if os.path.exists(cookies_file): |
456 | | - | # cookies_obj = cookielib.MozillaCookieJar(cookies_file) |
457 | | - | # cookies_obj.load(ignore_discard=True, ignore_expires=True) |
458 | | - | |
459 | 456 | | future = request_method(url=url_probe, headers=headers, |
460 | 457 | | allow_redirects=allow_redirects, |
461 | 458 | | timeout=timeout, |
| skipped 198 lines |
660 | 657 | | parser.add_argument("--json", "-j", metavar="JSON_FILE", |
661 | 658 | | dest="json_file", default=None, |
662 | 659 | | help="Load data from a JSON file or an online, valid, JSON file.") |
| 660 | + | parser.add_argument("--cookie", metavar="COOKIE_FILE", |
| 661 | + | dest="cookie_file", default=None, |
| 662 | + | help="File with cookies.") |
663 | 663 | | parser.add_argument("--timeout", |
664 | 664 | | action="store", metavar='TIMEOUT', |
665 | 665 | | dest="timeout", type=timeout_check, default=10, |
| skipped 220 lines |
886 | 886 | | id_type=id_type, |
887 | 887 | | debug=args.verbose, |
888 | 888 | | logger=logger, |
| 889 | + | cookies=args.cookie_file, |
889 | 890 | | forced=args.use_disabled_sites, |
890 | 891 | | max_connections=args.connections, |
891 | 892 | | ) |
| skipped 62 lines |