[Newbies] problems pulling data from a url..

David Mitchell david.mitchell at gmail.com
Thu Mar 25 14:34:00 UTC 2010

(HTTPSocket httpGet: aUrl) contents

I know we Smalltalkers like to talk about how no one ever gets confused
about dynamic types, but it does happen ;-).

The stream has the text you want. May want to familiarize yourself with core
methods on the Stream hierarchy.

Pushing the Stream through a ByteArray conversion is invoking printString.

Your trouble with getting a modified string using replaceAll: is again a
subtle typing error:

Reading the comment for #replaceAll:with:
"Replace all occurences of oldObject with newObject"

But, Strings are collections of characters, not strings. Compare:

'foo' replaceAll: 'f' with: 'g'
'foo' replaceAll:  $f with: $g

Take a look at senders of #findString:

Many of them do replacements of substrings.

David Mitchell

On Wed, Mar 24, 2010 at 12:44 AM, sergio_101 <sergiolist at village-buzz.com>wrote:

> i am currently using HTTPSocket to pull data from a url...
> looks like this:
>        | data |
>        data := String
>                                fromByteArray: (HTTPSocket httpGet: anUrl).
> i end up with a string that has my desired data (a JSON string), but,
> it's preceeded by this:
> 'a RWBinaryOrTextStream ' '<here is the stuff i need>' ' '
> i am trying to lop off the first part by doing:
> jsonData := dataString replaceAll:  'RWBinaryOrTextStream' with: 'test'.
> just to see if i can touch the string..
> but no matter what i do, i can't get any parts of the string to be
> raplaced..
> it almost looks like there are three strings in there..
> the RWBinaryOrTextStream one, the one i need, and an empty one..
> is there a better way to pull a url?
> thanks!
> --
> ----
> peace,
> sergio
> photographer, journalist, visionary
> http://www.coffee-black.com
> http://www.painlessfrugality.com
> http://www.twitter.com/sergio_101
> http://www.facebook.com/sergio101
> _______________________________________________
> Beginners mailing list
> Beginners at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/mailman/listinfo/beginners
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/beginners/attachments/20100325/214c6cf4/attachment.htm

More information about the Beginners mailing list