[Newbies] problems pulling data from a url..
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.
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
> 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?
> photographer, journalist, visionary
> Beginners mailing list
> Beginners at lists.squeakfoundation.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Beginners