On Thu, Jun 18, 2009 at 6:58 AM, Juo H.[email protected] wrote:
Hey, I tried that
[code]
rapidshare = data.to_xml.write($stdout, 1)
This is setting rapidshare to whatever the String#write method which
is an extension to the String class provided by scrubyt.
It looks like it actually returns the number of characters written,
letâs say for arguments sake that you write 42 characters, the
actually value doesnât matter since:
rapidshare.to_s
This evaluates to â42â or whatever the string representation of the
return value from String#write was, and then does noting with the
result.
Maybe something like:
rapidshare = data.to_xml
rapidshare.write($stdout, 1)
which would make rapidshare reference the result of data.to_xml (which
Iâm assuming here is a string.
Now to the real meat,
rapidshare = rapidshare.delete(<âlinkâ>)
As Inigo Montoya would say, âI donât think that method means what you
think it means.â
irb(main):001:0> âif l < k and k < j then j > lâ.delete(ââ)
=> "f ad j the j "
String#delete removes ANY characters which are in the argument from
the receiver.
If you are sure that the string in rapidshare is well formed then you
could use something like
print rapidshare.gsub(%r{</?link>}, ââ)
or
rapidshare = rapidshare.gsub(%r{</?link>}, ââ)
print rapidshare
Putting it all together
require ârubygemsâ
require âscrubytâ
data = Scrubyt::Extractor.define do
fetch âmywebsite.com is available for purchase - Sedo.comâ
fill_textfield âuserâ, âmyusernameâ
fill_textfield âpasswrdâ, âmypasswordâ
submit
fetch âhttp://mywebsite/index.php?topic=672â
link â//div/codeâ
end
rapidshare = data.to_xml
rapidshare.write($stdout, 1)
print rapidshare.gsub(%r{</?link>}, ââ)
â
Rick DeNatale
Blog: http://talklikeaduck.denhaven2.com/
Twitter: http://twitter.com/RickDeNatale
WWR: http://www.workingwithrails.com/person/9021-rick-denatale
LinkedIn: http://www.linkedin.com/in/rickdenatale