Last active
July 13, 2021 16:57
-
-
Save sorz/5577181 to your computer and use it in GitHub Desktop.
Revisions
-
bluen revised this gist
Jan 14, 2014 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -13,6 +13,7 @@ def convert_line(line): return line[1:-1] line = line.replace('*', '.+') line = line.replace('(', r'\(').replace(')', r'\)') if line.startswith('||'): return '^https?:\/\/%s.*' % line[2:] elif line.startswith('|'): -
BlueN created this gist
May 14, 2013 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,47 @@ #!/usr/bin/env python #encoding: utf-8 import urllib2 from base64 import b64decode LIST_URL = 'https://autoproxy-gfwlist.googlecode.com/svn/trunk/gfwlist.txt' BLACK_FILE = 'gfw.url_regex.lst' WHITE_FILE = 'cn.url_regex.lst' def convert_line(line): if line[0] == '/' and line[-1] == '/': return line[1:-1] line = line.replace('*', '.+') if line.startswith('||'): return '^https?:\/\/%s.*' % line[2:] elif line.startswith('|'): return '^%s.*' % line[1:] elif line[-1] == '|': return '.*%s$' % line else: return '.*%s.*' % line def convert(gfwlist): black = open(BLACK_FILE, 'w') white = open(WHITE_FILE, 'w') for l in gfwlist.split('\n'): l = l[:-1] if not l or l[0] == '!' or l[0] == '[': continue if l.startswith('@@'): white.write(convert_line(l[2:]) + '\n') else: black.write(convert_line(l) + '\n') def main(): src = urllib2.urlopen(LIST_URL).read() src = b64decode(src) convert(src) if __name__ == '__main__': main()