从Google获取在某个地方花费的平均时间

时间:2017-04-25 16:32:04

标签: java android google-maps jsoup

我正在尝试使用jsoup直接从Google的搜索结果中提取平均花费的时间;因为Google API目前不支持获取该信息。

例如,

网址为“https://www.google.com/search?q=vivocity”,提取的文字为“15分钟到2小时”

我尝试过以下代码

try {
        String url = "https://www.google.com.sg/search?q=vivocity";
        Document doc = Jsoup.connect(url).userAgent("mozilla/17.0").get();
        Elements ele = doc.select("div._B1k");

        for (Element qwer:ele){
            temp += "Avg time spent: " + qwer.getElementsByTag("b").first().text() + "\n";
        }
    }

    catch (IOException e){
        e.printStackTrace();
    }

我也试过输出doc.text()并搜索输出,它似乎也没有包含任何与平均时间有关的内容。

奇怪的是,对于其他网址和div,它们的工作非常好。

任何帮助将不胜感激,谢谢。

0 个答案:

没有答案