How to search for a query with more than one word using Ruby HTTParty? -
so have code looks keyword in website: http://www.recipepuppy.com/api. def self.for(keyword)
function looks keyword in website. chocolate
example below works, however, if have 2 or more words search results comes blank. wondering how can compensate this. appreciated!
require 'httparty' class recipe include httparty base_uri 'recipepuppy.com' default_params output: "json" format :json def self.for(keyword) get("/api", query: {q: keyword}) end end puts recipe.for("chocolate") puts puts recipe.for("apple pie")
results:
{"title"=>"tim , tracy's chocolate cake (boiled)", "href"=>"http://www.recipezaar.com/tim-and-tracys-chocolate-cake-boiled-259680", "ingredients"=>"baking soda, butter, cocoa powder, eggs, flour, sugar, water", "thumbnail"=>"http://img.recipepuppy.com/34464.jpg"} {"title"=>"chocolate tea", "href"=>"http://www.recipezaar.com/chocolate-tea-205348", "ingredients"=>"milk, sugar, tea bag, water", "thumbnail"=>""} {"title"=>"chocolate-toffee cream pie", "href"=>"http://www.recipezaar.com/chocolate-toffee-cream-pie-82097", "ingredients"=>"pie crust, toffee baking bits, cool whip, cream cheese, brown sugar, candy bars, vanilla extract, heavy cream", "thumbnail"=>""} {"title"=>"chocolate chocolate chocolate butterscotch chip cookies recipe", "href"=>"http://www.grouprecipes.com/50195/chocolate-chocolate-chocolate-butterscotch-chip-cookies.html", "ingredients"=>"cocoa powder, baking soda, brown sugar, butterscotch chips, eggs, flour, milk chocolate, salt, semisweet chocolate chips, sugar, vanilla extract", "thumbnail"=>"http://img.recipepuppy.com/231970.jpg"} {"title"=>"chocolate cake fruits recipe", "href"=>"http://www.grouprecipes.com/43318/chocolate-cake-with-fruits.html", "ingredients"=>"baking powder, baking soda, chocolate cake, eggs, frosting, vanilla extract, vanilla extract, salt, salt", "thumbnail"=>"http://img.recipepuppy.com/304911.jpg"} {"title"=>"chocolate chip cookies", "href"=>"http://www.recipezaar.com/chocolate-chip-cookies-146432", "ingredients"=>"flour, baking soda, chocolate, eggs, brown sugar, corn syrup, nuts, salt, semisweet chocolate, butter, vanilla bean, sugar", "thumbnail"=>"http://img.recipepuppy.com/306284.jpg"} {"title"=>"chocolate macadamia cookies white chocolate chunks", "href"=>"http://www.recipezaar.com/chocolate-macadamia-cookies-with-white-chocolate-chunks-271061", "ingredients"=>"flour, almond extract, baking soda, brown sugar, butter, shortening, eggs, salt, sugar, macadamia nuts, cocoa powder, white chocolate", "thumbnail"=>""} {"title"=>"chocolate-dipped brownie bites (brownies)", "href"=>"http://www.recipezaar.com/chocolate-dipped-brownie-bites-brownies-264833", "ingredients"=>"flour, baking soda, butter, eggs, chocolate, salt, semisweet chocolate chips, shortening, sugar, vanilla extract, water", "thumbnail"=>"http://img.recipepuppy.com/311066.jpg"} {"title"=>"darn chocolate cake ( cake mix cake)", "href"=>"http://www.recipezaar.com/darn-good-chocolate-cake-cake-mix-cake-87205", "ingredients"=>"frosting, cake mix, eggs, chocolate pudding, sour cream, vegetable oil, water", "thumbnail"=>"http://img.recipepuppy.com/42112.jpg"} {"title"=>"angelina?s hot chocolate", "href"=>"http://www.recipezaar.com/angelinas-hot-chocolate-334398", "ingredients"=>"chocolate, water, milk, sugar, water, whipped cream", "thumbnail"=>"http://img.recipepuppy.com/62411.jpg"} # apple pie function; part blank #
change
base_uri 'recipepuppy.com'
to
base_uri 'www.recipepuppy.com'
their api screwed , somehow fixes it...
Comments
Post a Comment