Last active
December 6, 2022 04:21
-
-
Save aileron/a3f6f016e6b0a3d59625ffa265fb6783 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'nokogiri' | |
html = <<HTML | |
<main> | |
<div>plain div</div> | |
<div class="test">test</div> | |
<div class="test">test</div> | |
</main> | |
HTML | |
nokogiri = Nokogiri::HTML(html) | |
p nokogiri.css("main > div:not([class])") | |
p nokogiri.xpath("/main/div[not(@class)]") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
css では取れるけど、xpath で指定する方法判らなかった