contenu(y)
----------------------
Here the error:
88:in 'contenu': undefined method 'text' for nil:NilClass
(NoMethodError)from 95:in '<main>'
----------------------
My question: why the price-line(prix) work differently of the two others
before her?
She works fine if i put a number, and don't work with the "nb" whithout
.to_i.
This may be a link with the character € (it's for that the -2 at line
90, because it show "?" instead).
If you are french, i am too, et mon anglais n'est pas assez avancé pour
tout comprendre en cette langue.
looks like 'css("span")[4]' is returning nil
insert a line before line 88:
inspect @page.css("tr")[nb.to_i].css("span")
to see if the data matches what you expect
···
On Sat, Oct 26, 2013 at 9:33 PM, Romain Vass <lists@ruby-forum.com> wrote:
Hello all,
here is my method lines 85-92:
def contenu(nb) @titre = @page.css("tr")[nb.to_i].css("h2").css("a").text @lieu = @page.css("tr")[nb.to_i].css("a").css("p")[0].text @prix = @page.css("tr")[nb.to_i].css("span")[4].text
puts @titre
puts @lieu+'|'+@prix[0..-2]
puts '---'
end
----------------------
Here his call at line 95:
contenu(y)
----------------------
Here the error:
88:in 'contenu': undefined method 'text' for nil:NilClass
(NoMethodError)from 95:in '<main>'
----------------------
My question: why the price-line(prix) work differently of the two others
before her?
She works fine if i put a number, and don't work with the "nb" whithout
.to_i.
This may be a link with the character € (it's for that the -2 at line
90, because it show "?" instead).
If you are french, i am too, et mon anglais n'est pas assez avancé pour
tout comprendre en cette langue.
D:/Documents and
Settings/Administrator/Desktop/jpe/JPE-Complet/JPE-C.rb:92:
in `inspect': wrong number of arguments(1 for 0) (ArgumentError)
from D:/Documents and
Settings/Administrator/Desktop/jpe/JPE-Complet/JPE-C.rb:92:in `contenu'
from D:/Documents and
Settings/Administrator/Desktop/jpe/JPE-Complet/JPE-C.rb:100:in `<main>'
On Sat, Oct 26, 2013 at 10:43 PM, Romain Vass <lists@ruby-forum.com> wrote:
D:/Documents and
Settings/Administrator/Desktop/jpe/JPE-Complet/JPE-C.rb:92:
in `inspect': wrong number of arguments(1 for 0) (ArgumentError)
from D:/Documents and
Settings/Administrator/Desktop/jpe/JPE-Complet/JPE-C.rb:92:in `contenu'
from D:/Documents and
Settings/Administrator/Desktop/jpe/JPE-Complet/JPE-C.rb:100:in `<main>'
it should print the object
from your code you should see an array of at least 4 items, since you are
trying to grab the fourth
If it is printing a list of less then 4 items, or is nil, thats the cause
of the error
the job then is to figure out why your input is not as you expect
···
On Sun, Oct 27, 2013 at 9:12 AM, Romain Vass <lists@ruby-forum.com> wrote:
@page.css("tr")[nb.to_i].css("span").inspect
that make no error