Ich versuche, die src
Wert eines Blocks von HTML zu bekommen. Ich versuche speziell, dies unter Verwendung der at_css
und nicht mit XPath zu erreichen.Wie bekomme ich die Img src mit Nokogiri und at_css
Bis jetzt alles, was ich bekomme, ist entweder Null oder eine leere Zeichenfolge.
Dies ist der HTML:
<div class="" id="imageProductContainer">
<a id="idLinkProductMainImage" href='URL'>
<img id="productMainImage" src="SRC.jpg" alt="alt" title="A Title" align="left" class="product_image_productpage_main selectorgadget_selected">
</a>
</div>
Der Code, den ich habe, ist:
item = page.doc.at_css("#productMainImage img").text.strip unless page.doc.at_css("#productMainImage img").nil?
puts item #prints blank
item = item["src"]
puts item #prints blank
Wo page.doc
das Element Nokogiri HTML ist.
Perfekt, danke !! –