返回列表 发帖

用python解决amule中文乱码的问题

原文在这里
  1. #!/usr/bin/env python
  2. #-*- coding:utf-8 -*-

  3. import urllib2
  4. import re
  5. from sys import argv, exit
  6. def main(url):
  7.     fd = urllib2.urlopen(url)
  8.     data = fd.read()
  9.     fd.close()
  10.     p = re.compile(r'ed2k="(.*|/)"')
  11.     matches = p.findall(data)
  12.     if matches:
  13.         for l in matches:
  14.             print urllib2.unquote(l)

  15. if __name__ == '__main__':
  16.     if len(argv) < 2:
  17.         print 'one argument is necessary'
  18.         exit(2)
  19.     main(argv[1])
复制代码

返回列表