-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathhide_my_python.py
executable file
·62 lines (52 loc) · 1.87 KB
/
hide_my_python.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env python3
# -*- coding: utf8 -*-
#
# HideMyPython! - A parser for the free proxy list on HideMyAss!
#
# This file contains the main function of the HideMyPython! script.
# It parses the arguments, creates a database, and save the proxies.
#
# Copyright (C) 2013 Yannick Méheut <useless (at) utouch (dot) fr>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import sys
import arguments
import parser
import database
def main():
# We create an argument parser
arg_parser = arguments.create_argument_parser()
# We parse the arguments
args = arg_parser.parse_args(sys.argv[1:])
arguments.process_arguments(args, arg_parser)
# If the verbose mode is on, we display the arguments
if args.verbose:
arguments.print_arguments(args)
# We open the database file where the proxies will be stored
connection, cursor = database.initialize_database(args.database_file)
try:
# We generate the proxies
for proxy in parser.generate_proxy(args):
# And we store them in the database
database.insert_in_database(cursor, proxy)
except KeyboardInterrupt:
if args.verbose:
print('')
print('[warn] received interruption signal')
# We save the changes made to the database, and close the file
connection.commit()
connection.close()
return 0
if __name__ == '__main__':
main()