如何通过Array获取所有文本 [英] How to get all text by Array
问题描述
< p ng-if =!me.adminclass =sv ng-binding ng-scopeng-repeat =x in user.groups | orderBy > NASS InfoPass计划程序< / p>
< p ng-if =!me.adminclass =sv ng-binding ng-scopeng-repeat =x in user.groups | orderBy> NASS Adjudications Scheduler< ; / p>
如何使用 使用 .nokogiri.org /rel =nofollow> Nokogiri 您可以将文本解压缩为 How can I use With Nokogiri you can extract the text as
这篇关于如何通过Array获取所有文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! class =sv ng-binding ng-scope
require'nokogiri '
#假设您将HTML文本存储在变量html中
html =<< EOF
< p ng-if =!me.admin类=sv ng-binding ng-scopeng-repeat =x in user.groups | orderBy> NASS InfoPass Scheduler< / p>
< p ng-if =!me.adminclass =sv ng-binding ng-scopeng-repeat =x in user.groups | orderBy> NASS Adjudications Scheduler< / p& r< / p>
EOF
doc = Nokogiri :: HTML(html)
p doc.css('。sv.ng-binding.ng-scope')。map(&; text )
#=> [NASS InfoPass Scheduler,NASS Adjudications Scheduler]
<p ng-if="!me.admin" class="sv ng-binding ng-scope" ng-repeat="x in user.groups | orderBy">NASS InfoPass Scheduler</p>
<p ng-if="!me.admin" class="sv ng-binding ng-scope" ng-repeat="x in user.groups | orderBy">NASS Adjudications Scheduler</p>
class="sv ng-binding ng-scope"
as a Array to get text?require 'nokogiri'
# suppose you store your HTML text in variable `html'
html = <<EOF
<p ng-if="!me.admin" class="sv ng-binding ng-scope" ng-repeat="x in user.groups | orderBy">NASS InfoPass Scheduler</p>
<p ng-if="!me.admin" class="sv ng-binding ng-scope" ng-repeat="x in user.groups | orderBy">NASS Adjudications Scheduler</p>r</p>
EOF
doc = Nokogiri::HTML(html)
p doc.css('.sv.ng-binding.ng-scope').map(&:text)
#=> ["NASS InfoPass Scheduler", "NASS Adjudications Scheduler"]