def save(self): db = DBClient() #将新抓取的代理存入raw_proxy for value in self.ip: db.put(value[0], value[1]) #存入verified_proxy db.changeTable('verified_proxy') for value in self.ip: #如果verified_proxy已有此代理,则不再覆盖写入 if (not db.isKeyExists(value[0])): db.put(value[0], '0')
def recipe_save(name="Mystery Recipe"): # curl -X PUT --data-urlencode "json=sample.json" http://10.73.212.155:8080/recipes/marlowe # curl -X PUT --data-urlencode "json=cand_sf1.json" http://10.73.212.155:8080/recipes/marlowe apiPath = os.getcwd() path = apiPath + "/../Data/" jsonName = request.forms.get("json") # print jsonName filepath = path + jsonName f = open(filepath, 'r') for line in f: try: content = line.strip() print content content = content.replace("\'", "\"") client = DBClient() resultID = client.put(content) except Exception, em: continue