id喜欢为我的网站提取prodirectselect.com产品,问题是有3个尺寸选项(欧盟/英国/美国),我只想要使用Xpath的欧盟尺寸,所以这是网站来源:
<option data-uksize="6" data-eusize="39⅓" data-ussize="6½" data-persmaxchars="0" data-persmaxnums="0" data-perscanhaveflag="" data-status="" data-msg1="Available for Immediate Dispatch. " data-msg2="" value="6">39⅓</option >
所以Xpath是 // * [@ ID = “大小”]
它只是提取英国尺寸,我需要的是欧盟尺寸所以我应该添加到Xpath?
答案 0 :(得分:0)
您的问题写得不是很好(例如,您没有提供确切网页的网址)
我去了一个随机的鞋子入口(http://www.prodirectselect.com/products/Nike-Zoom-All-Out-Flyknit-Black-WhiteCool-GreyVolt-Mens-Shoes-844134002-137750.aspx?)
正如我猜测那是你所追求的那种页面的一个例子。
尺码部分(//*[@id="size"]
)
是:
<select name="size" id="size" class="medium">
<option value="">Please select a size</option><option data-uksize="6" data-eusize="40" data-ussize="7" data-persmaxchars="0" data-persmaxnums="0" data-perscanhaveflag="" data-status="" data-msg1="Available for Immediate Dispatch. " data-msg2="" value="6">6</option>
<option data-uksize="6½" data-eusize="40½" data-ussize="7½" data-persmaxchars="0" data-persmaxnums="0" data-perscanhaveflag="" data-status="" data-msg1="Available for Immediate Dispatch. " data-msg2="" value="6.5">6½</option>
<option data-uksize="7" data-eusize="41" data-ussize="8" data-persmaxchars="0" data-persmaxnums="0" data-perscanhaveflag="" data-status="" data-msg1="Available for Immediate Dispatch. " data-msg2="" value="7">7</option>
<option data-uksize="7½" data-eusize="42" data-ussize="8½" data-persmaxchars="0" data-persmaxnums="0" data-perscanhaveflag="" data-status="" data-msg1="Available for Immediate Dispatch. " data-msg2="" value="7.5">7½</option>
<option data-uksize="8" data-eusize="42½" data-ussize="9" data-persmaxchars="0" data-persmaxnums="0" data-perscanhaveflag="" data-status="" data-msg1="Available for Immediate Dispatch. " data-msg2="" value="8">8</option>
<option data-uksize="8½" data-eusize="43" data-ussize="9½" data-persmaxchars="0" data-persmaxnums="0" data-perscanhaveflag="" data-status="" data-msg1="Available for Immediate Dispatch. " data-msg2="" value="8.5">8½</option>
<option data-uksize="9" data-eusize="44" data-ussize="10" data-persmaxchars="0" data-persmaxnums="0" data-perscanhaveflag="" data-status="" data-msg1="Available for Immediate Dispatch. " data-msg2="" value="9">9</option>
<option data-uksize="9½" data-eusize="44½" data-ussize="10½" data-persmaxchars="0" data-persmaxnums="0" data-perscanhaveflag="" data-status="" data-msg1="Available for Immediate Dispatch. " data-msg2="" value="9.5">9½</option>
<option data-uksize="10" data-eusize="45" data-ussize="11" data-persmaxchars="0" data-persmaxnums="0" data-perscanhaveflag="" data-status="" data-msg1="Available for Immediate Dispatch. " data-msg2="" value="10">10</option>
<option data-uksize="10½" data-eusize="45½" data-ussize="11½" data-persmaxchars="0" data-persmaxnums="0" data-perscanhaveflag="" data-status="" data-msg1="Available for Immediate Dispatch. " data-msg2="" value="10.5">10½</option>
<option data-uksize="11" data-eusize="46" data-ussize="12" data-persmaxchars="0" data-persmaxnums="0" data-perscanhaveflag="" data-status="" data-msg1="Available for Immediate Dispatch. " data-msg2="" value="11">11</option>
<option data-uksize="11½" data-eusize="47" data-ussize="12½" data-persmaxchars="0" data-persmaxnums="0" data-perscanhaveflag="" data-status="" data-msg1="Available for Immediate Dispatch. " data-msg2="" value="11.5">11½</option>
<option data-uksize="12" data-eusize="47½" data-ussize="13" data-persmaxchars="0" data-persmaxnums="0" data-perscanhaveflag="" data-status="" data-msg1="Available for Immediate Dispatch. " data-msg2="" value="12">12</option>
</select>
因此,要获得您需要的欧盟尺寸清单:
//*[@id="size"]/option/@data-eusize