使用 jsoup 抓取 <div class= "nutrition-label" > 中的数据



我想在 <div class="nutrition-label">中刮擦数据 使用JSOUP我正在使用: Element element = doc.select("div.nutrition-label");元素总是空的,有帮助吗?该网站是http://caloriecount.about.com/calories-bananas-i9040问候

您请求的网站无法识别您的用户,这会导致您进入一个空元素。

将用户设置为以下类似内容应呈现您所需的结果。

Document doc = Jsoup.connect(url).userAgent("Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1667.0 Safari/537.36").get();
        Elements el = doc.select("div.nutrition-label");

最新更新