如何检查推特用户声明的位置是否存在?

How can I check whether the location declared by a twitter's user exists?

我正在做一个 Twitter 爬虫,我已经使用 Lucene 在其上构建了一个搜索引擎。由于许多用户提交了不存在的位置(例如 "in my kitchen"、"wonderland"、"from LA to Paris"...),我想我应该检查哪些用户根据他们的位置建立索引,或者通过位置搜索使他们可以到达更远的地方。我通过抽取英文推文来检索用户(使用 TwitterStream.sample("en"))。

我的第一个想法是从一些网站下载世界上所有城市,然后检查是否有匹配项。然而,这种方法存在一个问题:很难找到一份包含世界上所有城市的文档,这些城市以所有可能的语言拼写。事实上,用户可以用英语或他自己的语言提交他所在城市(或国家)的名称。

您需要使用地理编码 google maps, yandex maps

I'm facing the fact that the first link tells google API look for cities in USA by default. So...if a user says he's in "Paris", google API will response me NO_REPONSE

Red Light District

I have read the first link with much attention and the second link with less attention, because the latter seems to be useful just for javascript application (I'm doing all in java).

没有。这是不正确的。您可以通过 HTTP 请求获取信息,参考 HTTP request parameters.

yandex maps using apache http client

的一小段代码
private void request(String geocode) throws IOException {
        HttpResponse response = Request.Post(SEARCH_URL).version(HttpVersion.HTTP_1_1)
                .bodyForm(createForm(geocode).build(), Charsets.UTF_8).useExpectContinue()
                .connectTimeout(CONNECTION_TIMEOUT_MILS)
                .socketTimeout(CONNECTION_TIMEOUT_MILS)
                .execute().returnResponse();

        assertStatus(response, geocode);
        getCoordinatesFromResponse(response, geocode);
    }

    private Form createForm(String geocode) {
        return Form.form().add("format", "json").add("results", "1").add("geocode", geocode);
    }

    private void assertStatus(HttpResponse response, String requestString) {
        StatusLine statusLine = response.getStatusLine();
        if (statusLine.getStatusCode() >= ERROR_STATUS_MIN) {
            throw new RuntimeException(String.format(
                    "Error sending request '%s' to the map service, server response: %s",
                    requestString, response));
        }
    }