• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python unirest.get函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中unirest.get函数的典型用法代码示例。如果您正苦于以下问题:Python get函数的具体用法?Python get怎么用?Python get使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: _dispatch

   def _dispatch(self, urls):
      with self.lock:
         for link in urls:
            # Avoid exploring the same page twice.
            if link in self.seen:
               continue

            try:
               # TODO: Should be removed in final version.
               # If it's a local file, just go ahead and read the file.
               if link.startswith('/'):
                  class ResponseDummy:
                     def __init__(self, file):
                        self.body = open(file)
                  syncCB = partial(self._callback, self.router.match(link))
                  Thread(target=syncCB, args=(link, ResponseDummy(link))).start()
               # TODO: stop removing dummy code here.

               else:
                  # Request page contents asynchronously.
                  get(link, callback=partial(self._callback, self.router.match(link), link))

               self.seen.add(link)
               self.pending += 1

            except Router.NoMatchError as e:
               print 'Could not find handler endpoint for {0}.'.format(str(e))
开发者ID:alfinoc,项目名称:events,代码行数:27,代码来源:collect.py


示例2: describeImage

def describeImage(imgPath):
	response = unirest.post("https://camfind.p.mashape.com/image_requests",
	  headers={
	    "X-Mashape-Key": "You meshape key, register at meshape https://market.mashape.com/imagesearcher/camfind"
	  },
	  params={
	    "image_request[image]": open(imgPath, mode="r"),
	    "image_request[language]": "en",
	    "image_request[locale]": "en_US"
	  }
	)
	
	token=response.body['token']
	
	response = unirest.get("https://camfind.p.mashape.com/image_responses/" + token,
	  headers={
	    "X-Mashape-Key": "aiYZkTIXj7mshNul9uy1GrEoIZYOp1QdFbGjsn3AexvpbfgD3g",
	    "Accept": "application/json"
	  }
	)
	
	while (response.body['status']!="completed" and response.body['status']!="skipped"):
		time.sleep(1) #sleep for 1 seconds
		response = unirest.get("https://camfind.p.mashape.com/image_responses/" + token,
		  headers={
		    "X-Mashape-Key": "aiYZkTIXj7mshNul9uy1GrEoIZYOp1QdFbGjsn3AexvpbfgD3g",
		    "Accept": "application/json"
		  }
		)
	
	#assume completed
	if (response.body['status']!="skipped"):
		return response.body['name']
	else:
		return "unsuccessful"
开发者ID:ronentk,项目名称:RPI-Visual-Queries,代码行数:35,代码来源:camFind.py


示例3: identify_image

def identify_image(inputFileURL):
    response = unirest.post("https://camfind.p.mashape.com/image_requests",
  headers={
    "X-Mashape-Key": "9UyIuOYhCKmshb72Y27ctmWYJReGp1G3LaBjsndZ3QPhPjjHMl"
  },
  params={
    "focus[x]": "480",
    "focus[y]": "480",
    "image_request[language]": "en",
    "image_request[locale]": "en_US",
    "image_request[remote_image_url]": ""+str(inputFileURL)+""
  }
)

    token = response.body['token'] # The parsed response
    print token
    response2 = unirest.get("https://camfind.p.mashape.com/image_responses/"+str(token),
  headers={
    "X-Mashape-Key": "9UyIuOYhCKmshb72Y27ctmWYJReGp1G3LaBjsndZ3QPhPjjHMl"
  }
)
    time.sleep(1)
    while (response2.body['status'] == 'not completed'):
        response2 = unirest.get("https://camfind.p.mashape.com/image_responses/"+str(token),
    headers={
        "X-Mashape-Key": "9UyIuOYhCKmshb72Y27ctmWYJReGp1G3LaBjsndZ3QPhPjjHMl"
    }
    )
    print "Sleeping"
    time.sleep(1)

    #print response2.body
    print response2.raw_body
开发者ID:b44p,项目名称:b44p,代码行数:33,代码来源:get_street_view_heading.py


示例4: detail_view

def detail_view(request, recipe_id, ingredients):
    ingredients = ingredients.split('+') # list of ingredients owned

    response = unirest.get("https://spoonacular-recipe-food-nutrition-v1.p.mashape.com/recipes/" + recipe_id + "/information",
      headers={
        "X-Mashape-Key": "QN5CLcAiQXmshOrib4vl7QifQAPjp1MjXoijsnsKdgztp93FnI"
      }
    )

    needed = []

    for ingredient in response.body["extendedIngredients"]:
        needed.append(ingredient["name"])

    missing = list(set(needed) - set(ingredients))

    print missing

    recipe = unirest.get("https://spoonacular-recipe-food-nutrition-v1.p.mashape.com/recipes/extract?forceExtraction=false&url=http%3A%2F%2F" + response.body['sourceUrl'][7:].replace("/", "%2F") + "",
      headers={
        "X-Mashape-Key": "QN5CLcAiQXmshOrib4vl7QifQAPjp1MjXoijsnsKdgztp93FnI"
      }
    )
    context = {
        'recipe': response.body,
        'directions': recipe.body
    }

    return render(request, 'recipe_detail.html', context)
开发者ID:alexander-ma,项目名称:coyote,代码行数:29,代码来源:views.py


示例5: get_information

def get_information(url):
    """Get information for url using webscraping and API calls."""

    all_info = []

    scrape_info = get_all_recipe_info(url)

    response1 = unirest.get("https://spoonacular-recipe-food-nutrition-v1.p.mashape.com/recipes/extract?forceExtraction=false&url=%s" % url,
        headers={
            "X-Mashape-Key": os.environ['MASHAPE_KEY']
        }
    )
    api_info = response1.body
    recipe_api_id = api_info['id']

    #instructions for recipe through api request
    response2 = unirest.get("https://spoonacular-recipe-food-nutrition-v1.p.mashape.com/recipes/%s/analyzedInstructions?stepBreakdown=true" % recipe_api_id,
        headers={
            "X-Mashape-Key": os.environ['MASHAPE_KEY'],
            "Accept": "application/json"
        }
    )
    instruction_info = response2.body[0]['steps']

    all_info.append(scrape_info)
    all_info.append(api_info)
    all_info.append(instruction_info)

    return all_info
开发者ID:ibhan88,项目名称:Project---Vegan-Recipes,代码行数:29,代码来源:seed.py


示例6: get_class_collection

def get_class_collection(player_class):
    response = unirest.get(
        "https://omgvamp-hearthstone-v1.p.mashape.com/cards/classes/" + player_class + "?collectible=1",
        headers={"X-Mashape-Key": "HFXwiln4KJmshs6B1jOMfsA75kg3p1Jj1qOjsntjBvnGaWzx1v"},
    )

    classCards = json.dumps(response.body, indent=1, separators=(",", ": "))

    classCardsDict = json.loads(classCards)

    removeHeroes = list()

    for x in classCardsDict:
        if x["type"] != "Hero":
            removeHeroes.append(x)

    response2 = unirest.get(
        "https://omgvamp-hearthstone-v1.p.mashape.com/cards/types/Minion?collectible=1",
        headers={"X-Mashape-Key": "HFXwiln4KJmshs6B1jOMfsA75kg3p1Jj1qOjsntjBvnGaWzx1v"},
    )

    minionCards = json.dumps(response2.body, indent=1, separators=(",", ": "))

    minionCardsDict = json.loads(minionCards)

    neutralCardsDict = list()

    for y in minionCardsDict:
        if "playerClass" not in y:
            neutralCardsDict.append(y)

    collection = removeHeroes + neutralCardsDict

    return collection
开发者ID:bmg64,项目名称:HSDeckAssistant-CS1520,代码行数:34,代码来源:main.py


示例7: __init__

 def __init__(self, url):
     self.tournaments_data, self.return_code = json.dumps(unirest.get(url, headers={"Accept":"application/json"}).body), \
     unirest.get(url).code
     checkCode(self.return_code)
     self.parsed_data = json.loads(self.tournaments_data)
     self.past = {}
     self.setTournamentsAttributes(self.parsed_data)
开发者ID:SunshineAPI,项目名称:sunshine4py,代码行数:7,代码来源:tournaments.py


示例8: __init__

 def __init__(self, name, url):
     self.name = name
     self.player_data, self.return_code = json.dumps(unirest.get('http://' + url, header={"Accept":"application/json"}).body), \
     unirest.get('http://' + url).code
     checkCode(self.return_code)
     parsed_data = json.loads(self.player_data)
     self.dict_name=''
     self.setPlayerAttributes(parsed_data)
开发者ID:SunshineAPI,项目名称:sunshine4py,代码行数:8,代码来源:player.py


示例9: question

def question(qid):
    url = settings.API_URL + 'question/' + qid
    response = unirest.get(url, headers={'Content-Type':'application/json'}, params={'embedded':'{"post":1}'})
    answers  = unirest.get(settings.API_URL + 'answer/?question=' + qid, headers={'Content-Type':'application/json'})

    response.body['answer'] = answers.body['data']
    response.body['nAnswers'] = len(response.body['answer'])

    return render_template('question.html', data=response.body)
开发者ID:lowellbander,项目名称:lineage,代码行数:9,代码来源:app.py


示例10: test_timeout

    def test_timeout(self):
        unirest.timeout(3)
        response = unirest.get("http://httpbin.org/delay/1")
        self.assertEqual(response.code, 200)

        unirest.timeout(1)
        try:
            response = unirest.get("http://httpbin.org/delay/3")
            self.fail("The timeout didn't work")
        except:
            pass
开发者ID:Mondego,项目名称:pyreco,代码行数:11,代码来源:allPythonContent.py


示例11: runApiRequest

	def runApiRequest(self,request):
		"""
		Method that run a api request
		"""
		#print "Getting information..."
		#We launch a first request
		try:
			self.response = unirest.get(request,
				  headers={
					"X-Mashape-Key": self.apiKey,
					"Accept": "text/plain"
				  }
				)
			#print "OK"
		except Exception:
			print "Error! Can't get any response from the api!"

		#if there is a response
		if self.response != None:
			#if this response is good
			if self.response.code == 200:
				#we notify the user that the request was successful
				return True
		else:

			#else we try again for a fixed number of try
			numberOfTry=1

			while (numberOfTry <self.maxTry):

				print "Try number {0}".format(numberOfTry)
				time.sleep(self.timeout)

				try:
					self.response = unirest.get(request,
						  headers={
							"X-Mashape-Key": self.apiKey,
							"Accept": "text/plain"
						  }
						)

					if self.response.code == 200:
						return True

				except Exception:
					print "Failed ! Try again in {0} secs".format(self.timeout)


				numberOfTry+=1


			return False
开发者ID:Jacobe2169,项目名称:Manga-Extractor,代码行数:52,代码来源:manga.py


示例12: __init__

 def __init__(self, urls):
     stats_data, self.return_code = unirest.get(urls[0], headers={"Accept":"application/json"}).body['data'], \
                                    unirest.get(urls[0]).code
     checkCode(self.return_code)
     for url in urls:
         self.return_code = unirest.get(url).code
         checkCode(self.return_code)
         if urls.index(url) == 0:
             continue
         stats_data += unirest.get(url, headers={"Accept":"application/json"}).body['data']
     self.setStats(stats_data)
     self.stats = stats_data
     print 'Retreived information for ' + str(len(stats_data)) + ' players.'
开发者ID:SunshineAPI,项目名称:sunshine4py,代码行数:13,代码来源:stat.py


示例13: run

    def run(self):
        print "Base Worker Listening"

        while 1:
           # print  "Hey Im working"

            #Keep listening there is no customer yet in store
            if orderQueue.empty():
                #Chill
                time.sleep(random.randint(10, 100) / 80.0)
                continue
            else:
                #Hey there is a Customer in my shop.
                item = self.__queue.get()

                #for demo sleep
                time.sleep(random.randint(10, 100) / 50.0)


                #parse to get Customer Info
                customer_channel = parseInfo(item)
                print "Connecting to "+customer_channel

                print "Asking Customer (Burrito/Bowl)"
                #for demo sleep
                time.sleep(random.randint(10, 100) / 50.0)
                #Lets ask him his requirements Burrito/Bowl
                responseBase = unirest.get("http://"+customer_channel+"/getBase", headers={ "Accept": "application/json" },
                                       params={ "base": "Tortilla/Bowl" })

                #If customer replies with his choice, Process order and send to next worker
                if responseBase.code==200:
                    print "I will add Delicious "+responseBase.body+" for you !"
                    baseValue = responseBase.body

                print "Asking Customer (Brown/White Rice)"
                #for demo sleep
                time.sleep(random.randint(10, 100) / 50.0)
                #Lets ask user which type of Rice he wants.
                responseRice = unirest.get("http://"+customer_channel+"/getRice", headers={ "Accept": "application/json" },
                                       params={ "rice": "Brown,White" })

                #If customer replies with his choice, Process order and send to next worker
                if responseRice.code==200:
                    print "I will add Delicious "+responseRice.body+" for you !"
                    self.cursor = self.connection.cursor()
                    self.cursor.execute("INSERT INTO Orders(CustomerName, Stage ) VALUES ( '{0}', '{1}')".format(parseCustomerInfo(item),"1"))
                    self.connection.commit()
                    self.cursor.close()
                    riceValue = responseRice.body
                    sendToNextWorker(item,baseValue,riceValue)
开发者ID:amoghrao2003,项目名称:ChipotleSimulation,代码行数:51,代码来源:BaseWorker.py


示例14: test_not_your_objects

def test_not_your_objects():
    first_image_response = unirest.post(hostname + '/enroll-image/',
        params={"image": open("./arnold.jpg", mode="r"), "label":"Arnold Schwarzenegger"})
    assert first_image_response.code == 200
    training_set_id = first_image_response.body['id']
    training_set_response = unirest.get(hostname + '/trainingset/' + training_set_id + '/')
    assert training_set_response.code == 200
    unirest.clear_default_headers()
    random_username = ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(8))
    permissions_response = unirest.get(hostname + '/trainingset/' + training_set_id + '/',
        headers={"X-Mashape-User":random_username, "X-Mashape-Proxy-Secret":"DEBUG"})
    print permissions_response.code
    print permissions_response.body
    assert permissions_response.code != 200
开发者ID:danlipert,项目名称:hyperlayer-api-test,代码行数:14,代码来源:test_api.py


示例15: getData

def getData(name):
    try:
        print "fetching " + name + " data..."
        get_data = unirest.get("https://vikhyat-hummingbird-v2.p.mashape.com/anime/" + name, 
                               headers={"X-Mashape-Key": "key"})
        if(get_data.code == 404):
            name = re.sub('s-', '-s-', name, 1)
            print "trying " + name + "..."
            get_data = unirest.get("https://vikhyat-hummingbird-v2.p.mashape.com/anime/" + name, 
                                   headers={"X-Mashape-Key": "key"})
        return get_data

    except Exception as err:
        print err()
        return None
开发者ID:opk1,项目名称:mal_bot,代码行数:15,代码来源:bot.py


示例16: __init__

 def __init__(self, urls):
     print urls
     self.teams_data, self.return_code = json.dumps(unirest.get(urls[0],  headers={'Accept':'application/json'}).body), unirest.get(urls[0]).code
     checkCode(self.return_code)
     self.parsed_data = json.loads(self.teams_data)
     for url in urls:
         if urls.index(url) == 0:
             pass
         else:
             self.parsed_data['data'] += json.loads(json.dumps(unirest.get(url, headers={'Accept':'application/json'}).body))['data']
             self.return_code = unirest.get(url).code
             checkCode(self.return_code)
     self.teams = {}
     self.team_list = []
     self.setTeamList(self.parsed_data)
开发者ID:SunshineAPI,项目名称:sunshine4py,代码行数:15,代码来源:teams.py


示例17: hello_world

def hello_world():
	response = unirest.get("https://daxeel-abbreviations-v1.p.mashape.com/all/" + request.args.get('a'),
	  headers={
	    "X-Mashape-Key": "key"
	  }
	)    
	return response.raw_body
开发者ID:dustinupdyke,项目名称:pyabbreviations,代码行数:7,代码来源:app.py


示例18: run

    def run(self):
        print "Garnish Worker Listening"
        while 1:
         #   print  "Hey Im working: MeatWorker"

            #Keep listening there is no customer yet in store
            if garnishQueue.empty():
                #Chill
                time.sleep(random.randint(10, 100) / 50.0)
                continue
            else:
                #Hey there is a Customer in my shop.
                item = self.__queue.get()
                #parse to get Customer Info
                customer_channel = parseInfo(item)
             #   print "Connecting to "+customer_channel

                print "Asking Customer (Cheese/Guacamole/Lettuce)"
                #for demo sleep
                time.sleep(random.randint(10, 100) / 50.0)
                #Lets ask him his requirements Burrito/Bowl
                responseGarnish = unirest.get("http://"+customer_channel+"/getGarnish", headers={ "Accept": "application/json" },
                                       params={ "sauce": "Cheese,Guacamole,Lettuce" })
                #If customer replies with his choice, Process order and send to next worker
                if responseGarnish.code==200:
                    garnishValue = responseGarnish._body
                    self.cursor = self.connection.cursor()
                    print "I will add Delicious "+responseGarnish.body+" for you !"
                    self.cursor.execute("UPDATE  Orders SET Stage ='{0}' WHERE CustomerName = '{1}'".format("4",parseCustomerInfo(item)))
                    self.connection.commit()
                    self.cursor.close()
                    sendToNextWorker(item,garnishValue)
开发者ID:amoghrao2003,项目名称:ChipotleSimulation,代码行数:32,代码来源:GarnishWorker.py


示例19: GetCurrentScore

    def GetCurrentScore(self, word):

        url = "https://montanaflynn-dictionary.p.mashape.com/define?word=" + word

        # These code snippets use an open-source library.
        response = unirest.get(url,
            headers={
                "X-Mashape-Key": "j6rDcjfVcVmshxp0Y102O2cL6vDrp16mL1FjsnsgRqpcl6fC3L",
                "Accept": "application/json"
            }
        )

        resp = word + '\n\n'

        data = json.dumps(response.body, separators=(',',':'))
        meanings = (json.loads(data))["definitions"]
        
        count = 0
        for meaning in meanings:
            count = count + 1
            resp = resp + 'm' + str(count) +' : ' + str(meaning["text"]) + '\n\n'

        # Create Text response
        text_response = str(resp)

        #Return details
        return str(text_response)
开发者ID:deephpatel92,项目名称:weather,代码行数:27,代码来源:layer.py


示例20: sms

def sms(request):
    pid = str(request.POST.get("pid", ""))
    phno = str(request.POST.get("phno", ""))
    plast = str(request.POST.get("plast", ""))
    pnext = str(request.POST.get("pnext", ""))
    pstatus = str(request.POST.get("pstatus", ""))

    print (phno)
    msg = (
        "YOUR PARCEL WITH ID : "
        + pid
        + " IS AT "
        + plast
        + ". NEXT STATION : "
        + pnext
        + ". STATUS : "
        + pstatus
        + "- Regards : MIST Courier Services."
    )

    print (msg)

    response = unirest.get(
        "https://site2sms.p.mashape.com/index.php?msg=" + msg + "&phone=" + phno + "&pwd=nsknsp10&uid=9494473579",
        headers={"X-Mashape-Key": "8Mm8na6YEamsh3KZtQjBfHVXQjl4p1nM6G7jsntyy4P1F2By56", "Accept": "application/json"},
    )

    cont = {"phno": phno, "pid": pid}
    return render(request, "profile.html", cont)
开发者ID:sr1k4n7h,项目名称:DjangoAcademicProject,代码行数:29,代码来源:views.py



注:本文中的unirest.get函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python unirest.post函数代码示例发布时间:2022-05-27
下一篇:
Python unique_id.toMsg函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap