Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
关于什么
html_doc.xpath('//b//a')[0..10].each do |element| imgurl = BASE + element.attributes['href'].value #imgname = element.attributes['innerText'] imgname = element.content puts imgname ... end
element.text或者element.inner_text应该在您的情况下提供相同的输出
element.text
element.inner_text