Jsoup选择了两个<div>

时间:2015-05-26 07:56:28

标签: java jsoup

我在一个网页上工作,有一个div标签,它本身有两个div, 一个div有一个名为padt-10的类,另一个div有一个名为txt28的类。 我必须提取第一个div的图像源,以及第二个div的文本。

我的代码工作正常,但它不会打印第二个div的所有元素! 所以它让我很困惑。

这是ezdihaar元素的第一个元素 THis is the first Element of ezdihaar elements

Document doc;
    try {
    doc = Jsoup.connect("http://deals.souq.com/sa-ar/?id_tag=48&pid_tag=103").get();
    Elements maindiv =  doc.select("div");
    Elements ezdihaar =  maindiv.select("div.padt-10,div.txt28"); 

for(int e=0; e <ezdihaar.size();e++)
{ 

System.out.println(""+ezdihaar.get(e).select("img").attr("src")+"");
System.out.println(""+ezdihaar.get(e).select("div.txt28").text());  

}

这是输出

http://cf3.souqcdn.com/items/item/79/54/46/8/item_L_20150520141412_7954468.jpg



2222 ريـال




http://cf1.souqcdn.com/item/2015/02/02/78/12/97/5/item_L_7812975_6807766.jpg



777 ريـال




http://cf4.souqcdn.com/items/item/78/07/88/1/item_L_20150514185244_7807881.jpg



499 ريـال




http://cf3.souqcdn.com/items/item/79/66/48/0/item_L_20150330132840_7966480.jpg



2444 ريـال




http://cf1.souqcdn.com/items/item/78/07/88/0/item_L_20150514190123_7807880.jpg





http://cf2.souqcdn.com/items/item/82/55/70/6/item_L_20150519140114_8255706.jpg



3888 ريـال




http://cf5.souqcdn.com/items/item/82/55/65/7/item_L_20150519140312_8255657.jpg





http://cf2.souqcdn.com/items/item/71/03/79/4/item_L_20150410074721_7103794.jpg



599 ريـال




http://cf5.souqcdn.com/items/item/47/50/56/8/item_L_20150519112226_4750568.jpg



1599 ريـال




http://cf4.souqcdn.com/items/item/75/02/50/0/item_L_20150524173210_7502500.jpg



388 ريـال




http://cf5.souqcdn.com/items/item/46/92/53/4/item_L_20150215134157_4692534.jpg



1499 ريـال




http://cf1.souqcdn.com/items/item/71/82/45/2/item_L_20150414133124_7182452.jpg



699 ريـال




http://cf3.souqcdn.com/items/item/81/60/51/2/item_L_20150519052020_8160512.jpg



2099 ريـال




http://cf4.souqcdn.com/items/item/82/55/40/1/item_L_20150513125827_8255401.jpg



2333 ريـال




http://cf5.souqcdn.com/items/item/82/55/81/0/item_L_20150513125718_8255810.jpg



2666 ريـال




http://cf2.souqcdn.com/items/item/82/55/82/1/item_L_20150513125635_8255821.jpg



3299 ريـال




http://cf3.souqcdn.com/items/item/82/55/21/6/item_L_20150514083301_8255216.jpg



3033 ريـال




http://cf4.souqcdn.com/items/item/82/55/76/9/item_L_20150514083148_8255769.jpg





http://cf2.souqcdn.com/items/item/75/02/51/0/item_L_20150524173326_7502510.jpg





http://cf2.souqcdn.com/items/item/77/20/81/8/item_L_20150430090952_7720818.jpg



222 ريـال




http://cf4.souqcdn.com/item/2013/11/03/46/85/79/0/item_L_4685790_3575542.jpg





http://cf1.souqcdn.com/items/item/67/06/05/4/item_L_20150524075440_6706054.jpg



215 ريـال




http://cf4.souqcdn.com/items/item/82/55/79/5/item_L_20150514083016_8255795.jpg





http://cf5.souqcdn.com/items/item/82/55/67/3/item_L_20150513125533_8255673.jpg





http://cf2.souqcdn.com/items/item/46/30/37/7/item_L_20150115090404_4630377.jpg



555 ريـال




http://cf2.souqcdn.com/items/item/72/54/17/4/item_L_20150422054030_7254174.jpg



1999 ريـال




http://cf4.souqcdn.com/items/item/82/55/63/2/item_L_20150514082901_8255632.jpg





http://cf1.souqcdn.com/items/item/67/92/56/7/item_L_20150420062034_6792567.jpg



410 ريـال




http://cf1.souqcdn.com/items/item/82/55/78/3/item_L_20150519130204_8255783.jpg





http://cf4.souqcdn.com/items/item/76/00/93/0/item_L_20150409120758_7600930.jpg



420 ريـال




http://cf4.souqcdn.com/items/item/56/18/39/6/item_L_20150423095348_5618396.jpg



399 ريـال




http://cf2.souqcdn.com/item/2013/08/05/55/88/07/1/item_L_5588071_2620090.jpg





http://cf1.souqcdn.com/items/item/67/92/58/5/item_L_20150517095958_6792585.jpg





http://cf3.souqcdn.com/item/2014/12/21/76/63/20/0/item_L_7663200_6474359.jpg



888 ريـال




http://cf1.souqcdn.com/items/item/69/90/00/2/item_L_20150324134244_6990002.jpg



1444 ريـال




http://cf2.souqcdn.com/items/item/81/05/60/1/item_L_20150524075052_8105601.jpg





http://cf5.souqcdn.com/items/item/67/93/32/7/item_L_20150519064536_6793327.jpg



قم بإيجاد الصفقة المناسبة!

0 个答案:

没有答案