[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

fabsy

8/18/2006 2:00:00 PM

Hey.. I just installed hpricot but it acts strange..
I tried an example from
http://code.whytheluckystiff.net/hpricot/wiki/Hpr... but it
didn't work.. It just gave me "test.rb:1: parse error, unexpected
tIDENTIFIER, expecting $"...

After that i tried ruby -ropen-uri -e
'eval(open("http://balloon.hobix.com/hpr...).read)' and it launched
the script on that page without any problems..
I tried to copy that script and pasted it into my texteditor to just
try to launch it but it gave me the :

"test.rb:1: parse error, unexpected tIDENTIFIER, expecting $
puts "You may use XPath (//span[@class='entryPermalink']) or CSS
selectors (spanendlements.each { |ele| pp ele } }t? [h/I]? "ts found."


What does that mean? And why doesn't it work? I followed the steps from
:
http://hivelogic.com/articles/2005/12/01/ruby_rails_lighttpd_m...

9 Answers

Chris Gehlker

8/18/2006 2:52:00 PM

0


On Aug 18, 2006, at 7:00 AM, fabsy wrote:

> Hey.. I just installed hpricot but it acts strange..
> I tried an example from
> http://code.whytheluckystiff.net/hpricot/wiki/Hpr... but it
> didn't work.. It just gave me "test.rb:1: parse error, unexpected
> tIDENTIFIER, expecting $"...

Maybe you better show us your actual code. There are several examples
on that page.

Look at this:

require 'rubygems'
require 'hpricot'
require 'open-uri'
doc = Hpricot(open("http://qwantz....))
(doc/"p/a/img").each do |img|
puts img.attributes['class']
end

It works although it doesn't actually find and image with a 'class'
attribute.


--
Seven Deadly Sins? I thought it was a to-do list!


fabsy

8/18/2006 2:57:00 PM

0


Chris Gehlker skrev:

> On Aug 18, 2006, at 7:00 AM, fabsy wrote:
>
> > Hey.. I just installed hpricot but it acts strange..
> > I tried an example from
> > http://code.whytheluckystiff.net/hpricot/wiki/Hpr... but it
> > didn't work.. It just gave me "test.rb:1: parse error, unexpected
> > tIDENTIFIER, expecting $"...
>
> Maybe you better show us your actual code. There are several examples
> on that page.
>
> Look at this:
>
> require 'rubygems'
> require 'hpricot'
> require 'open-uri'
> doc = Hpricot(open("http://qwantz....))
> (doc/"p/a/img").each do |img|
> puts img.attributes['class']
> end
>
> It works although it doesn't actually find and image with a 'class'
> attribute.
>
>
> --
> Seven Deadly Sins? I thought it was a to-do list!

Im getting the same error with the code you pasted..

Chris Gehlker

8/18/2006 4:07:00 PM

0


On Aug 18, 2006, at 8:00 AM, fabsy wrote:

>
> Chris Gehlker skrev:
>
>> On Aug 18, 2006, at 7:00 AM, fabsy wrote:
>>
>>> Hey.. I just installed hpricot but it acts strange..
>>> I tried an example from
>>> http://code.whytheluckystiff.net/hpricot/wiki/Hpr... but it
>>> didn't work.. It just gave me "test.rb:1: parse error, unexpected
>>> tIDENTIFIER, expecting $"...
>>
>> Maybe you better show us your actual code. There are several examples
>> on that page.
>>
>> Look at this:
>>
>> require 'rubygems'
>> require 'hpricot'
>> require 'open-uri'
>> doc = Hpricot(open("http://qwantz....))
>> (doc/"p/a/img").each do |img|
>> puts img.attributes['class']
>> end
>>
>> It works although it doesn't actually find and image with a 'class'
>> attribute.
>>
>>
>> --
>> Seven Deadly Sins? I thought it was a to-do list!
>
> Im getting the same error with the code you pasted..

Weird,

I'm running ruby 1.8.5 (2006-08-18) [powerpc-darwin8.7.0] with
Hpricot 0.4.43 and I just cut and pasted the above code. It still
works. I'm stumped.

---
Conscience is thoroughly well-bred and soon leaves off talking to
those who do not wish to hear it.
-Samuel Butler, writer (1835-1902)




fabsy

8/18/2006 5:54:00 PM

0


Chris Gehlker skrev:

> On Aug 18, 2006, at 8:00 AM, fabsy wrote:
>
> >
> > Chris Gehlker skrev:
> >
> >> On Aug 18, 2006, at 7:00 AM, fabsy wrote:
> >>
> >>> Hey.. I just installed hpricot but it acts strange..
> >>> I tried an example from
> >>> http://code.whytheluckystiff.net/hpricot/wiki/Hpr... but it
> >>> didn't work.. It just gave me "test.rb:1: parse error, unexpected
> >>> tIDENTIFIER, expecting $"...
> >>
> >> Maybe you better show us your actual code. There are several examples
> >> on that page.
> >>
> >> Look at this:
> >>
> >> require 'rubygems'
> >> require 'hpricot'
> >> require 'open-uri'
> >> doc = Hpricot(open("http://qwantz....))
> >> (doc/"p/a/img").each do |img|
> >> puts img.attributes['class']
> >> end
> >>
> >> It works although it doesn't actually find and image with a 'class'
> >> attribute.
> >>
> >>
> >> --
> >> Seven Deadly Sins? I thought it was a to-do list!
> >
> > Im getting the same error with the code you pasted..
>
> Weird,
>
> I'm running ruby 1.8.5 (2006-08-18) [powerpc-darwin8.7.0] with
> Hpricot 0.4.43 and I just cut and pasted the above code. It still
> works. I'm stumped.
>
> ---
> Conscience is thoroughly well-bred and soon leaves off talking to
> those who do not wish to hear it.
> -Samuel Butler, writer (1835-1902)

I'ts really strange.. It works in irb but not when im pasting in in a
..rb file..
Maby I should re-install it?

Chris Gehlker

8/18/2006 6:07:00 PM

0


On Aug 18, 2006, at 10:55 AM, fabsy wrote:

> I'ts really strange.. It works in irb but not when im pasting in in a
> .rb file..
> Maby I should re-install it?

Maybe. It seems to me that if it weren't installed correctly it
wouldn't work in irb either but I can't think of anything better to try.
--
Vegetarians eat Vegetables, Humanitarians frighten me



fabsy

8/18/2006 6:14:00 PM

0


Chris Gehlker skrev:

> On Aug 18, 2006, at 10:55 AM, fabsy wrote:
>
> > I'ts really strange.. It works in irb but not when im pasting in in a
> > .rb file..
> > Maby I should re-install it?
>
> Maybe. It seems to me that if it weren't installed correctly it
> wouldn't work in irb either but I can't think of anything better to try.
> --
> Vegetarians eat Vegetables, Humanitarians frighten me

Yeah.. re-installed it but i still get the same error..

I just pasted:

require 'rubygems'
require 'hpricot'
require 'open-uri'

doc = Hpricot(open("http://qwantz....))
(doc/"p/a/img").each do |img|
puts img.attributes['class']
end

into a file and tried to run it.. It gave me the
"hej.rb:1: parse error, unexpected tIDENTIFIER, expecting $
require 'open-uri'"

But it still works when i paste it directly into irb..

Chris Gehlker

8/18/2006 6:45:00 PM

0


On Aug 18, 2006, at 11:28 AM, Justin Collins wrote:

> Why is it saying parse error on line 1 if "require 'open-uri'" is
> on line 3 of your example?
> How are you running the file?

I think maybe Justin is on to something here. Could your editor be
messing up the end-of-lines? I'm using TextMate and not having any
problems.
--
Egotism is the anesthetic that dulls the pain of stupidity.
-Frank William Leahy, football coach (1908-1973)


phrogz

8/18/2006 8:09:00 PM

0

fabsy wrote:
> I just pasted:
>
> require 'rubygems'
> require 'hpricot'
> require 'open-uri'
>
> doc = Hpricot(open("http://qwantz....))
> (doc/"p/a/img").each do |img|
> puts img.attributes['class']
> end
>
> into a file and tried to run it.. It gave me the
> "hej.rb:1: parse error, unexpected tIDENTIFIER, expecting $
> require 'open-uri'"

Smells like you've got a line-endings problem.

fabsy

8/18/2006 10:01:00 PM

0


phrogz@gmail.com skrev:

> fabsy wrote:
> > I just pasted:
> >
> > require 'rubygems'
> > require 'hpricot'
> > require 'open-uri'
> >
> > doc = Hpricot(open("http://qwantz....))
> > (doc/"p/a/img").each do |img|
> > puts img.attributes['class']
> > end
> >
> > into a file and tried to run it.. It gave me the
> > "hej.rb:1: parse error, unexpected tIDENTIFIER, expecting $
> > require 'open-uri'"
>
> Smells like you've got a line-endings problem.

Aah!
I got a new texteditor and it works like a charm!
Thank you guys..