使用java将刮取的数据从网页存储到json对象
我从网页上抓取手机数据,我需要将该页面上所有手机的手机名称和价格输入json。下面是我的代码:
Elements mobilename = document.select(
"#products div.product-unit div.pu-title ");
Elements price = document.select(
"#products div.product-unit div.pu-price div.pu-final span.fk-font-17");
for(Element url1:mobilename)
{
text=url1.text();
System.out.println(text);
for(Element b:price)
{
text1= b.text();
System.out.println(text1);
arr1.add(text1);
arr1.add(text);
}
pa.put("price",text1 );
pa.put("name", text);
obj7.add(pa);
}
json.put("mobile:", obj7);
我正在为一页中的所有手机尝试以下内容:
{"mobile:":[{"price":"Rs. ","name":""}
共 (0) 个答案