document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. #!/usr/bin/env python
  2. __author__ = "Frank Xayachack"
  3. from bs4 import BeautifulSoup
  4. import urllib,urllib2,sys
  5.  
  6. def China_post(track_id):
  7.     url = "http://track-chinapost.com/result_chinapost.php"
  8.     payload = {\'code\':track_id,\'submit\':\'Start+Tracking\'}
  9.     payload = urllib.urlencode(payload)
  10.     req = urllib2.Request(url,payload)
  11.     request = urllib2.urlopen(req)
  12.     page = BeautifulSoup(request.read())
  13.     summary = page.find_all(\'table\')[2]
  14.     summary = summary.find_all(\'td\')
  15.     print """
  16.     ===============================================================================================
  17.     Tracking number   |   Origin                   |   Destination                   |   Status   |  
  18.     ===============================================================================================
  19.     """+summary[0].string+"""      """+summary[1].string+"""                  """+summary[2].string+"""            """+summary[3].string
  20.  
  21.  
  22.     detail = page.find_all(\'table\')[3]
  23.     detail = detail.find_all(\'td\')
  24.     print "\\n"
  25.  
  26.     for i in detail:
  27.         sys.stdout.write("\\t")
  28.         if (i.string==None):
  29.             print "\\n"
  30.             i.string = ""
  31.         sys.stdout.write("".join(i.string))
  32.         sys.stdout.write("      ")
  33.  
  34. China_post(sys.argv[1])
');