- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 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
import re, copy, json
config = {}
def domain_mapper(domain):
def injector(f):
if domain not in config:
config[domain] = []
config[domain].append(f)
return injector
def default(f):
config['default'] = [f]
return f
@domain_mapper("gmail.com")
@default
def google_filter(content):
regex = r"([^\!\?\.]*?offer.*?[\!\?\.])"
repl = r""
return re.sub(regex, repl, content, re.M)
@domain_mapper("gmail.com")
def another_google_filter(content):
return content
@domain_mapper("yandex.ru")
def yandex_filter(content):
regex = r"<img src=[\"'](.+?)[\"'].*/>"
repl = r"\1"
return re.sub(regex, repl, content, re.M)
@domain_mapper("mail.ru")
def mail_filter(content):
regex = r"<img src=[\"'](.+?)\.gif[\"'].*/>"
repl = r"<img src='\1.png'/>"
return re.sub(regex, repl, content, re.M)