gpt4 book ai didi

javascript - 从 flickr api/YQL 中提取城镇/城市

转载 作者:行者123 更新时间:2023-11-30 18:37:17 28 4
gpt4 key购买 nike

我正在尝试编写一个只返回一个人的村庄、城镇或城市的脚本。我正在使用以下 YQL 查询,但结果来自 console太具体了,他们先给我邻居。

select * from flickr.places where lat=51.558418 and lon=-1.781985 and api_key=YOU_FLICKR_API_KEY

这是我从控制台查询的结果。

<?xml version="1.0" encoding="UTF-8"?>
<query xmlns:yahoo="http://www.yahooapis.com/v1/base.rng"
yahoo:count="1" yahoo:created="2011-10-25T09:35:50Z" yahoo:lang="en-US">
<diagnostics>
<publiclyCallable>true</publiclyCallable>
<url execution-start-time="1" execution-stop-time="123" execution-time="122"><![CDATA[http://api.flickr.com/services/rest/?method=flickr.places.findByLatLon&lat=51.558418&lon=-1.781985]]></url>
<user-time>124</user-time>
<service-time>122</service-time>
<build-version>22535</build-version>
</diagnostics>
<results>
<places accuracy="16" latitude="51.558418" longitude="-1.781985" total="1">
<place latitude="51.547" longitude="-1.802"
name="West Leaze, Swindon, England, GB, United Kingdom"
place_id="sddCvK9SW703gg" place_type="neighbourhood"
place_type_id="22"
place_url="/United+Kingdom/England/Swindon/West+Leaze"
timezone="Europe/London" woeid="39722"/>
</places>
</results>
</query>

我希望能够更改查询中的 place_type_id。我知道我可以使用正则表达式来隔离信息,但我不确定这是否适用于所有位置,所以我更希望 API 只返回我想要的结果。

最佳答案

Flickr 的 flickr.places.findByLatLon 方法(由您的 YQL 查询在后台调用)接受一个 accuracy 键。

accuracy (Optional)

Recorded accuracy level of the location information. World level is 1, Country is ~3, Region ~6, City ~11, Street ~16. Current range is 1-16. The default is 16.

参见 » Flickr docs for flickr.places.FindByLatLon .

使用它就像在 where 子句中提供 accuracy =n 一样简单。大约 10 的值看起来与您正在寻找的准确度有关,但请试验一下以了解最佳值。

select * from flickr.places where 
lat=51.558418 and lon=-1.781985 and api_key=API_KEY_HERE
and accuracy=10

放在一边

通常可以通过查看表描述来获取 YQL 表所使用的数据源/服务的文档。

desc flickr.places

这提供了大量信息,通常包括至少一个指向文档页面的链接。请参阅 meta 部分以获取 documentationURL 项。

desc flickr.places

关于javascript - 从 flickr api/YQL 中提取城镇/城市,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7887350/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com