Assume I am in possession of a SERP API, which given a keyword, returns me the Google results of that keyword in JSON format (for example: https://serpapi.com/):
{
"organic_results": [
{
"position": 1,
"title": "Coffee - Wikipedia",
"link": "https://en.wikipedia.org/wiki/Coffee",
"displayed_link": "https://en.wikipedia.org › wiki › Coffee",
"snippet": "Coffee is a brewed drink prepared from roasted coffee beans, the seeds of berries from certain Coffea species. From the coffee fruit, the seeds are ...",
"sitelinks":{/*snip*/}
,
"rich_snippet":
{
"bottom":
{
"extensions":
[
"Region of origin: Horn of Africa and South Ara...",
"Color: Black, dark brown, light brown, beige",
"Introduced: 15th century"
]
,
"detected_extensions":
{
"introduced_th_century": 15
}
}
}
,
"about_this_result":
{
"source":
{
"description": "Wikipedia is a free content, multilingual online encyclopedia written and maintained by a community of volunteers through a model of open collaboration, using a wiki-based editing system. Individual contributors, also called editors, are known as Wikipedians.",
"source_info_link": "https://en.wikipedia.org/wiki/Wikipedia",
"security": "secure",
"icon": "https://serpapi.com/searches/6165916694c6c7025deef5ab/images/ed8bda76b255c4dc4634911fb134de53068293b1c92f91967eef45285098b61516f2cf8b6f353fb18774013a1039b1fb.png"
}
,
"keywords":
[
"coffee"
]
,
"languages":
[
"English"
]
,
"regions":
[
"the United States"
]
}
,
"cached_page_link": "https://webcache.googleusercontent.com/search?q=cache:U6oJMnF-eeUJ:https://en.wikipedia.org/wiki/Coffee+&cd=4&hl=en&ct=clnk&gl=us",
"related_pages_link": "https://www.google.com/search?q=related:https://en.wikipedia.org/wiki/Coffee+Coffee"
},
/* Results 2,3,4... */
]}
What is a good way to get new results from the past 24h? I added the &tbs=qdr:d query parameter, which only shows the results from the past day. That's a good first step.
The 2nd step is to filter out only relevant results. When there are no relevant results, Google shows this message box:
What is their algorithm to show this box?
Idea 1: "grep -i {exact_keywords}"
For example, if I search a keyword like "Alexander Pope", the 24h Google query might return results about the pope, written by a guy called Alexander. That's not super relevant. My naive idea is to grep (case insensitive) the exact keyword "Alexander Pope".
But that might leave out some good results.
Any other ideas?
I have a list of "usernames" as an array, and a list of posts in a mongodb collection with an "author" variable. I want to get all objects from the collection whose author is one of the usernames in the array.
so if:
Collection:
{
"author": "tim"
},
{
"author": "bob"
},
{
"author": "jon"
}
following = ["tim", "jon"]
then i only want to get the posts by tim and jon
I got the answer; it should be:
following = ["tim", "jon"]
mongo.db.posts.find({"author": {"$in": following}})
This will only get posts where the author is tim or jon.
In Amadeus API, in hotel search, in the result there is "chainCode", is there a list in csv of all chain codes ?
https://developers.amadeus.com/self-service/category/hotel/api-doc/hotel-search/api-reference
I'm referring to "chainCode" in this result example
{
"data": [
{
"type": "hotel-offers",
"hotel": {
"type": "hotel",
"hotelId": "XKPARC12",
"chainCode": "XK",
"dupeId": "501132260",
"name": "Holiday Inn Paris-notre Dame",
How to get the hotel chain name from "XK" in this example ?
sorry we totally missed this question. Since you cannot retrieve it via API, please take a look to the data-collection repository, which contains a list of Hotel chain codes.
I know that you can get quite a lot of information with calling:
http://store.steampowered.com/api/appdetails?appids=57690
But it is still missing data which available on the store page like rating, tags, etc. is there a parameter or another way to get more information about a game?
Yes, you can extract ratings information with the Steamworks User Reviews - Get List endpoint.
For example, to get info about CS:GO:
GET https://store.steampowered.com/appreviews/10?json=1&language=all
{
"success": 1,
"query_summary": {
"num_reviews": 20,
"review_score": 9,
"review_score_desc": "Overwhelmingly Positive",
"total_positive": 25703,
"total_negative": 898,
"total_reviews": 26601
},
"reviews": [
{
"recommendationid": "122478997",
"author": {
"steamid": "76561198072280507",
"num_games_owned": 3,
"num_reviews": 2,
"playtime_forever": 503225,
"playtime_last_two_weeks": 0,
"playtime_at_review": 503224,
"last_played": 1663589422
},
"language": "english",
"review": "God dam what a game",
"timestamp_created": 1663588856,
"timestamp_updated": 1663588856,
"voted_up": true,
"votes_up": 11,
"votes_funny": 2,
"weighted_vote_score": "0.643105804920196533",
"comment_count": 0,
"steam_purchase": true,
"received_for_free": false,
"written_during_early_access": false,
"hidden_in_steam_china": true,
"steam_china_location": ""
}
],
"cursor": "AoIFP+vAcEAAAAB6htXVAw=="
}
The query_summary returns global rating information about the game.
No, there isn't a public api endpoint for rating/tags etc.
The link you send isn't even officially supported by Valve as an API endpoint and is rate limited.
You can read through here for all the API endpoints of Steam, but the one you are using now is the only one with most of the game data in detail.
i searched a while but found nothing, thats simular to my problem.
i'm trying to use the YAHOO Weather API, for example: http://weather.yahooapis.com/forecastrss?w=4097
i don't know the WOEID in my case, but i got latitude and longitude points.
so my question is:
is there a way to get the WOEID of a place by using lat and long points?
This is now available through the recently released PlaceFinder API. Kudos to Yahoo! for providing yet another important piece of the Geo puzzle.
Yahoo! PlaceFinder API allows you to find a corresponding WOEID for a latitude/longitude pair. Consider this example web service method call:
http://where.yahooapis.com/geocode?location=37.42,-122.12&flags=J&gflags=R&appid=zHgnBS4m
You can play with request parameters according to your needs, see Yahoo! PlaceFinder API documentation for more.
And you should replace appid with your Yahoo! appid, you can create one here.
This request returns a response like that, which includes a lot of useful data along with the WOEID:
{
"ResultSet": {
"version": "1.0",
"Error": 0,
"ErrorMessage": "No error",
"Locale": "us_US",
"Quality": 99,
"Found": 1,
"Results": [
{
"quality": 99,
"latitude": "37.420000",
"longitude": "-122.120000",
"offsetlat": "37.420000",
"offsetlon": "-122.120000",
"radius": 500,
"name": "37.42,-122.12",
"line1": "3589 Bryant St",
"line2": "Palo Alto, CA 94306-4207",
"line3": "",
"line4": "United States",
"house": "3589",
"street": "Bryant St",
"xstreet": "",
"unittype": "",
"unit": "",
"postal": "94306-4207",
"neighborhood": "",
"city": "Palo Alto",
"county": "Santa Clara County",
"state": "California",
"country": "United States",
"countrycode": "US",
"statecode": "CA",
"countycode": "",
"hash": "",
"woeid": 12797284,
"woetype": 11,
"uzip": "94306"
}
]
}
}
This is not using Yahoo's API but I found this blog post:
http://geomojo.org/?p=38
Mentioning this service:
http://www.geomojo.org/cgi-bin/reversegeocoder.cgi?long=-117.699444&lat=35.4775
Perhaps you can use that? It solved my problem, I hope it helps in solving yours.
It is somewhat ridiculous that Yahoo doesn't provide a lookup method for WOEIDs via lat/lon--it's been on their todo list since 2008--but that's the state of things.
I would caution you against using the suggested workaround implemented at Geomojo. If it works for your data, great, but the Yahoo service that Geomojo relies on is unpredictable. Geomojo uses Yahoo's PlaceMaker, which extracts location information from unstructured text to get a WOEID. It does this by creating a microformat containing your lat/lon pair and submitting it to PlaceMaker. However, since PlaceMaker returns WOEIDs for zip codes there's a loss of resolution and you will sometimes not be able to identify even the town for submitted coordinates. I have a number of example points on the east coast of the U.S. where the PlaceMaker WOEIDs do not correspond to the submitted lat/lon pairs.
Strangely, as HD writes, only Flickr's API provides a simple way to lookup a WOEID from lat/lon. Flickr's findByLatLon method has great resolution. It will usually return a neighborhood (one level below town) for a pair of coordinates.
First get city name from lat/long using this code.
CLGeocoder *geocoder = [[CLGeocoder alloc] init] ;
[geocoder reverseGeocodeLocation:location
completionHandler:^(NSArray *placemarks, NSError *error) {
if (error){
NSLog(#"Geocode failed with error: %#", error);
return;
}
CLPlacemark *placemark = [placemarks objectAtIndex:0];
NSLog(#"cityname - %#",placemark.locality);
}];
Then use that cityname in below url
https://search.yahoo.com/sugg/gossip/gossip-gl-location/?appid=weather&output=sd1&p2=pt&command=YOURCITYNAME
Example - https://search.yahoo.com/sugg/gossip/gossip-gl-location/?appid=weather&output=sd1&p2=pt&command=sydney
This will return json and you find get WOEID in this...
{ "l" : { "gprid" : "eIL89mltSzSfgDWdP7uyBA" },
"q" : "sydney",
"r" : [ { "d" : "pt:iso=AU&woeid=1105779&lon=151.021&lat=-33.8563&s=New South Wales&c=Australia&sc=NSW&n=Sydney, Australia",
"k" : "Sydney"
} ]
}
Seems like you got it the wrong way around. This is the URL on weather.yahoo.com:
weather.yahoo.com/united-states/illinois/chicago-2379574/
The last bit is the WOEID for Chicago, i.e. 2379574
WOEIDs are described in the GeoPlanet docs:
http://developer.yahoo.com/geo/geoplanet/guide/concepts.html#woeids
You can use Flickr's reverse geocoding API through YQL.
Here is a link to the YQL with an example query to find the WOEID for a given lat/lon:
http://developer.yahoo.com/yql/console/#h=select%20place.woeid%20from%20flickr.places%20where%20lat%3D43%20and%20lon%3D-94
The above query can be called directly from your app with this URL (XML/JSON formats available):
http://query.yahooapis.com/v1/public/yql?q=select%20place.woeid%20from%20flickr.places%20where%20lat%3D43%20and%20lon%3D-94&format=xml
There is a topic about this issue at the YDN forums http://developer.yahoo.net/forum/index.php?showtopic=69
Looks like it's buried in the to-do list, from 2008 "The ability to map a set of longitude and latitude coordinates to a WOEID, from which information such as ZIP and State may be derived, has already been identified as a valuable feature and it is on our enhancement request list."
Other quotes;
"Flickr has a method: flickr.places.findByLatLon which returns a WOEID, but they truncate coordinates to three decimal places."
In this topic a Yahoo dev also suggests using the advice at http://geomojo.org/?p=38 as an interim solution.
Instead using lng & lat, you can use the current online IP Address to get the City Name then use Yahoo GeoPlanet web service to get the WOEID.
Follow this tutorial to get the detail: http://4rapiddev.com/php/get-woeid-of-a-city-name-from-ip-address-with-php/
The former Yahoo Weather API has became deprecated. The new Yahoo Weather API requires a query string to get weather.
Use the following query string to get weather data by latitude and longitude -
"https://query.yahooapis.com/v1/public/yql?q=select * from weather.forecast where woeid in (select woeid from geo.places(1) where text=\"(" + latitude + "," + longitude + ")\")&format=json"
Eg - https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20weather.forecast%20where%20woeid%20in%20(select%20woeid%20from%20geo.places(1)%20where%20text%3D%22(31.63%2C74.87)%22)&format=json
Yahoo api uses weather.com actually, so go to weather.com and search for your local weather. I'm in Chicago so I entered 'Chicago, IL' and here's the link in my browser bar showing my weather:
http://www.weather.com/weather/today/Chicago+IL+USIL0225?lswe=chicago,%20il&from=searchbox_localwx
In the link is the woeid - which is USIL0225
You can get yours the same way.