redirect_pas.py 838 B

1234567891011121314151617181920
  1. import re
  2. def redirect_pas(data, backlink):
  3. d_re = re.findall('\r\n#(?:redirect|넘겨주기) ((?:(?!\r|\n|%0D).)+)', data)
  4. for d in d_re:
  5. view = d.replace('\\', '')
  6. sh = ''
  7. s_d = re.search('#((?:(?!x27;|#).)+)$', d)
  8. if(s_d):
  9. href = re.sub('#((?:(?!x27;|#).)+)$', '', d)
  10. sh = '#' + s_d.groups()[0]
  11. else:
  12. href = d
  13. a = href.replace('&#x27;', "'").replace('&quot;', '"').replace('\\\\', '<slash>').replace('\\', '').replace('<slash>', '\\')
  14. backlink += [[title, a, 'redirect']]
  15. data = re.sub('\r\n#(?:redirect|넘겨주기) ((?:(?!\r|\n|%0D).)+)', '<meta http-equiv="refresh" content="0;url=/w/' + url_pas(a) + '/from/' + url_pas(title) + sh + '" />', data, 1)
  16. return([data, backlink])