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.
我想从中获取 parentID。
<div class="module-head" onclick="getURL('/DU/initAction.do?parentId=1063&categoryType=6')"></div>
我怎样才能做到这一点?
设置:
html = <<-EOF <div class="module-head" onclick="getURL('/DU/initAction.do?parentId=1063&categoryType=6')"></div> EOF
杏:
doc = Hpricot html
或 Nokogiri:
doc = Nokogiri::HTML html
有趣的是,两者都是一样的:
doc.at('div')[:onclick][/parentId=(\d+)/, 1] #=> "1063"