このXpathクエリをループ内に持っています。
//div[@class='listing_content'][#{i}]/div/div/h3/a/text()
各ノードを個別に処理したい
問題はそれが正しいノードを与えるが、それらすべてを一度に与える。
また、の場合i > 1
、何も返されませんか?
for i in (1...30)
name = page.xpath("//div[@class='listing_content'][#{i}]/div/div/h3/a/text()")
puts "this is name"
puts name
#Get Business phone
phone = page.xpath("//div[@class='listing_content'][#{i}]//span[@class='business-phone phone']/text()")
puts "this is phone"
puts phone
#Get Business website(if any)
puts "this is website"
website = page.xpath("//div[@class='listing_content'][#{i}]//li[@class='website-feature']//@href")
puts website
end