nokogiri

capistrano deploy can't install nokogiri

╄→гoц情女王★ 提交于 2020-02-25 07:44:32
问题 My cap production deploy is failing on nokogiri installation on an Ubuntu 12.04 box: DEBUG [6f355ce8] Extracting libxml2-2.8.0.tar.gz into tmp//ports/libxml2/2.8.0... OK DEBUG [6f355ce8] Running 'configure' for libxml2 2.8.0... ERROR, review 'tmp//ports/libxml2/2.8.0/configure.log' to see what happened. DEBUG [6f355ce8] *** extconf.rb failed *** DEBUG [6f355ce8] Make sure that `gem install nokogiri -v '1.6.1'` succeeds before bundling. I checked said logs and it mentions not finding a C

Image scraping in Ruby

一曲冷凌霜 提交于 2020-02-22 07:03:14
问题 How do I scrape an image present on a particular URL using Nokogiri? If there are better options than Nokogiri please suggest. The css image tag is .profilePic img 回答1: If it is just an <img> with a URL: PAGE = "http://site.com/page.html" require 'nokogiri' require 'open-uri' html = Nokogiri.HTML(open(PAGE)) src = html.at('.profilePic img')['src'] File.open("foo.png", "wb") do |f| f.write(open(src).read) end If you need to turn a relative image path into an absolute, see: https:/

Image scraping in Ruby

烈酒焚心 提交于 2020-02-22 07:02:30
问题 How do I scrape an image present on a particular URL using Nokogiri? If there are better options than Nokogiri please suggest. The css image tag is .profilePic img 回答1: If it is just an <img> with a URL: PAGE = "http://site.com/page.html" require 'nokogiri' require 'open-uri' html = Nokogiri.HTML(open(PAGE)) src = html.at('.profilePic img')['src'] File.open("foo.png", "wb") do |f| f.write(open(src).read) end If you need to turn a relative image path into an absolute, see: https:/

Image scraping in Ruby

不羁岁月 提交于 2020-02-22 07:01:06
问题 How do I scrape an image present on a particular URL using Nokogiri? If there are better options than Nokogiri please suggest. The css image tag is .profilePic img 回答1: If it is just an <img> with a URL: PAGE = "http://site.com/page.html" require 'nokogiri' require 'open-uri' html = Nokogiri.HTML(open(PAGE)) src = html.at('.profilePic img')['src'] File.open("foo.png", "wb") do |f| f.write(open(src).read) end If you need to turn a relative image path into an absolute, see: https:/

Can you search html attributes using wildcards with ruby nokogiri

廉价感情. 提交于 2020-02-02 13:49:06
问题 I know you can search text in html using wildcards. Can you search for attribute values in html using wildcards with nokogiri e.g., suppose I want to search for classes with value *session* 回答1: You can use xpath contains() function to search the document. Something like: doc.xpath("//*[@*[contains(., 'session')]]").each do |ele| # something end This search returns all the elements with any attribute whose value contains the string 'session'. 回答2: Had a similar problem few days ago - notice

“syntax error, unexpected tIDENTIFIER, expecting $end”

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-26 04:24:46
问题 I put together this script based on this tutorial. require 'nokogiri' require 'open-uri' url = "http://sfbay.craigslist.org/sby/jjj/" data = Nokogiri::HTML(open(url)) puts data.at_css('.itempn').text puts data.at_css('.itemcg').text I keep getting this error: Macintosh:nokogiri rgrush$ ruby aaa.rb aaa.rb:1: syntax error, unexpected tIDENTIFIER, expecting $end url = "http://sf... ^ Any ideas? Could it be that one of my dependencies is out of date? 回答1: most likely you have a non ASCII char in

Nokogiri Scraping Misses HTML

微笑、不失礼 提交于 2020-01-25 10:25:07
问题 Nokogiri isn't grabbing anything beneath the iframe tag. doc.search("iframe") returns only the iframe tag. doc.search("body.content-frame") returns empty. doc.errors returns empty also. Why isn't Nokogiri registering the HTML beneath the iframe? How can I grab it? <html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml"> <head></head> <body onunload="clearMyTimeInterval()"> <iframe id="content-frame" frameborder="0" src="/sportsbook/betting-lines/baseball/2014-08-21/?range=day"

Nokogiri gem install failing in Capistrano deploy

此生再无相见时 提交于 2020-01-25 01:40:25
问题 When attempting to install Nokogiri via bundler/capistrano I am receiving the error: An error occurred while installing nokogiri (1.6.5), and Bundler cannot continue Digging deeper I can see >> libxml2 version 2.6.21 or later is required! The error message also says Make sure that gem install nokogiri -v '1.6.5' succeeds before bundling. Well, as you can see this is not a problem: vagrant@vagrant:~$ gem install nokogiri -v '1.6.5' Building native extensions. This could take a while...

Can Nokogiri retain attribute quoting style?

心已入冬 提交于 2020-01-24 12:04:50
问题 Here is the contents of my file (note the nested quotes): <?xml version="1.0" encoding="utf-8"?> <property name="eventData" value='{"key":"value"}'/> in Ruby I have: file = File.read(settings.test_file) @xml = Nokogiri::XML( file) puts "@xml " + @xml.to_s and here is the output: <property name="eventData" value="{"key":"value"}"/> Is there a way to convert it so the output would preserve the quotes exactly? i.e. single on the outside, double on the inside? 回答1: No, it cannot. There is no

Can Nokogiri retain attribute quoting style?

耗尽温柔 提交于 2020-01-24 12:02:10
问题 Here is the contents of my file (note the nested quotes): <?xml version="1.0" encoding="utf-8"?> <property name="eventData" value='{"key":"value"}'/> in Ruby I have: file = File.read(settings.test_file) @xml = Nokogiri::XML( file) puts "@xml " + @xml.to_s and here is the output: <property name="eventData" value="{"key":"value"}"/> Is there a way to convert it so the output would preserve the quotes exactly? i.e. single on the outside, double on the inside? 回答1: No, it cannot. There is no