nokogiri

Nokogiri price doesn't show

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-13 05:09:01
问题 Can anyone explain how can I retrieve the value of the price using nokogiri? The values that appear on the scraper that I created are the this Costa Rica <span class="ProductListElement__price"> </span> India <span class="ProductListElement__price"> </span> Indonesia <span class="ProductListElement__price"> </span> Colombia <span class="ProductListElement__price"> </span> Nicaragua <span class="ProductListElement__price"> </span> Ethiopia <span class="ProductListElement__price"> </span>

Nokogiri: how to find the selected option of <select>?

对着背影说爱祢 提交于 2019-12-13 04:12:41
问题 I need to get a value of the selected HTML option: <select name="DisplayCurrency" id="DisplayCurrency" > <option value="GBP" >Pounds Sterling</option> <option value="EUR" selected="selected" >Euros</option> <option value="CHF" >Swiss Francs</option> <option value="DKK" >Danish Krona</option> <option value="CSK" >Czech Krowns</option> <option value="HUF" >Hungarian Forints</option> <option value="PLN" >Polish Zloty</option> </option> </select> I tried this using Nokogiri, but it does not work:

How to 'puts' a number list of items in the array using an 'until' loop

百般思念 提交于 2019-12-13 03:47:48
问题 I am using loops and a counter to put out a numbered list of items. It lists them all at once under 1, and then 2 is another round of listing of all of the items. The while loop doesn't work and I figured until was better. I also moved counter outside of the first iteriation but that doesn't work either. require 'pry' require 'rubygems' require 'open-uri' require 'nokogiri' class KefotoScraper::CLI def initialize @product_names = [] @page_url = "https://kefotos.mx/" end def call puts "These

nokogiri excluded elements from select all by class

蹲街弑〆低调 提交于 2019-12-13 03:47:26
问题 I'm just trying to exclude a couple of child elements by class from a selection of all the children of a node page.css('div.parent > *').each do |child| if (child["class"].content != 'this' && child["class"].content != 'that') array.push(child.text.to_s) end end I know this not the write syntax, but have been unable to find how to select an elements class, as opposed to selects and element by class. 回答1: The css method gives you Nokogiri::XML::Element instances and those get most of their

how to parse a row only if one of its fields is bold? Nokogiri and Ruby

拟墨画扇 提交于 2019-12-13 03:45:17
问题 so I have this code that collects all product info I need: # get main page page = agent.get "http://www.site.com.mx/tienda/index.php" search_form = page.forms.first search_result = agent.submit search_form doc = Nokogiri::HTML(search_result.body) rows = doc.css("table.articulos tr") i = 0 details = rows.collect do |row| detail = {} [ [:sku, 'td[3]/text()'], [:desc, 'td[4]/text()'], [:qty, 'td[5]/text()'], [:qty2, 'td[5]/p/b/text()'], [:price, 'td[6]/text()'] ].collect do |name, xpath| detail

What is nokogiri % encoding $ character

二次信任 提交于 2019-12-13 03:38:00
问题 Why do I get: Nokogiri::HTML('<a href="/test_$4b.html">test</a>').to_html => "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\" \"http://www.w3.org/TR/REC-html40/loose.dtd\">\n<html><body><a href=\"/test_%244b.html\">test</a></body></html>\n" I thought $ symbol was valid in the url? Followup: Why do browsers handle this differently. E.g. In the page: http://www.pmlive.com/pharma_news/its_on_shire_and_abbvie_agree_32bn_takeover_586969 The link: http://www.pmlive.com/pharma_news

replace <img> tag's src attribute from file content in rails

佐手、 提交于 2019-12-13 03:34:30
问题 Want to replace tag's src attribute value in xhtml file content. section_content = section.export_xhtml_content file_path doc = Nokogiri::HTML(section_content) unless doc.css('div.image_content').blank? doc.css('div.image_content img').each do |img| newsrc = File.basename img[:src] img.set_attribute('src', newsrc) end end Here src attribute get replaced. But getting XML Parsing Error: XML or text declaration not at start of entity error. After replacing src attribute, resultant content should

Sax Parsing strange element with nokogiri

允我心安 提交于 2019-12-13 02:26:45
问题 I want to sax-parse in nokogiri, but when it comes to parse xml element that have a long and crazy xml element name or a attribute on it.. then everthing goes crazy. Fore instans if I like to parse this xml file and grab all the title element, how do I do that with nokogiri-sax. <titles> <title xml:lang="sv">Arkivvetenskap</title> <title xml:lang="en">Archival science</title> </titles> 回答1: In your example, title is the name of the element. xml:lang="sv" is an attribute. This parser assumes

Error installing nokogiri, permission denied

懵懂的女人 提交于 2019-12-13 00:33:51
问题 When I type "gem install nokogiri" I receive the error: ERROR: While executing gem ... (Errno: EACCES) Permission denied - C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/ nokogiri-1.6.0-x86-mingw32/lib/nokogiri/1.9/nokogiri.so I have no idea what I need to do to fix this. Any help would be appreciated. 回答1: Try the below : gem install --http-proxy http://localhost:3128 _name_of_gem_ look here - How do I update Ruby Gems from behind a Proxy (ISA-NTLM) for more information. 回答2: Finally