示例#1
0
 def parseData(self, phone):
     payload = None
     # Check for 'data'
     try:
         dataType = "data"
         payload = self.service["data"]
     except KeyError:
         pass
     # Check for 'json'
     try:
         dataType = "json"
         payload = self.service["json"]
     except KeyError:
         pass
     # If payload is clean
     if not payload:
         payload = json.dumps({"url": self.service["url"]})
         dataType = "url"
     # Replace %phone%, etc.. to data
     for old, new in {
             "\'": "\"",
             "%phone%": phone,
             "%phone5%": numberTools.transformPhone(phone, 5),
             "%name%": randomData.random_name(),
             "%email%": randomData.random_email(),
             "%password%": randomData.random_password()
     }.items():
         payload = payload.replace(old, new)
     return (json.loads(payload), dataType)
示例#2
0
 def parseData(self, phone):
     payload = None
     # Check for 'data'
     if "data" in self.service:
         dataType = "data"
         payload = self.service["data"]
     # Check for 'json'
     elif "json" in self.service:
         dataType = "data"
         payload = self.service["json"]
     # Check for 'url'
     else:
         payload = json.dumps({"url": self.service["url"]})
         dataType = "url"
     # Replace %phone%, etc.. to data
     for old, new in {
             "\'": "\"",
             "%phone%": phone,
             "%phone5%": numberTools.transformPhone(phone, 5),
             "%name%": randomData.random_name(),
             "%email%": randomData.random_email(),
             "%password%": randomData.random_password(),
             "%token%": randomData.random_token()
     }.items():
         payload = payload.replace(old, new)
     return (json.loads(payload), dataType)