text: #coding=utf-8
  import sys
  import urllib
  import httplib
  import re
  import urlparse
  #import requests
  
  count = 100
  #httplib.HTTPConnection.debuglevel = 1
  
  def savefile(text):
      pass
  
  def checktitle(target):
      i = 1
      for i in range(count):
              url='http://' + target + '/?author=%s' % i
              pattern='<title>(.*) \|'
              try:
                      #r=requests.get(url)
                      r = urllib.urlopen(url).read()
              except  Exception,e:
                      print e
              #text=r.text
              text = r
              regux=re.compile(pattern)
              result=regux.findall(text)
              print result
              re_str=''.join(result)
              if re_str not in [u'\u672a\u627e\u5230\u9875\u9762']:
                      n_str=str(i)+':'+re_str
                      print n_str
                      #print "%d:%s" % (i,list)
  
  ## BUG: cannot get from Freebuf.com
  
  def checkurl(target):
      i = 1
      for i in range(count):
          conn = httplib.HTTPConnection(target)
          headers={"User-Agent":"Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"}  
          conn.request('GET','/?author=%s' % i,headers=headers)
          r = conn.getresponse()
          #print r.status
          if r.status == 301:
              url = 'http://' + target + '/?author=%s' % i
              a = urllib.urlopen(url).geturl()
              a = urlparse.urlparse(a)
              #print 'path:',a.path
              #astr = a.path[:-1]
              #astr = astr[astr.rindex('/')+1:]
              apos = a.path.rindex('/')
              bpos = len(a.path.split('/'))
              if apos == len(a.path)-1 :
                  print a.path.split('/')[bpos-2]
              else:
                  print a.path.split('/')[bpos-1]
              #print str(i) + ':' + astr
          
          
  
  def usage():
      print '<Usage>:'
      print '\t GetWPUser <type> <url>'
      print '<Type> :'
      print '\t 1 - From Title'
      print '\t 2 - From URL (Handler 302)'
      print '<Eg.>  :'
      print '\t GetWPUser 2 www.blackh4t.org'
      print ''
      print '\t\t\t by DarkR4y.'                
  
  def main():
      if len(sys.argv) == 3:
          t = sys.argv[1]
          target = sys.argv[2]
          if t == '1':
              checktitle(target)
          if t == '2':
              checkurl(target)
      else:
          usage()
      pass
  
  
  
  if __name__ == "__main__":
      main()
  				
  