Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/311.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用java将刮取的数据从网页存储到json对象_Java_Json - Fatal编程技术网

使用java将刮取的数据从网页存储到json对象

使用java将刮取的数据从网页存储到json对象,java,json,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");

我正在从网页上抓取手机数据,我需要将该网页上所有手机的手机名称和价格输入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":""}

使用一些库来处理json,例如使用json-simple-1.1.1.jar的iam