Re: strange behaviour in search for \n
Re: strange behaviour in search for \n
- Subject: Re: strange behaviour in search for \n
- From: Charles Arthur <email@hidden>
- Date: Thu, 1 Jul 2004 12:11:42 +0100
Hi ...
At 11:40 am +0100 on 1/7/04, Simon Forster wrote:
>
On 1 Jul 2004, at 10:52, Charles Arthur wrote:
>
>
> I've got a script that uses curl to download Amazon pages, and then
>
> extract
>
> the sales rank by searching for the key phrase - Sales rank:
>
> </b>\nXXXXX\n</font>
>
>
I imagine you're falling foul of the different line endings used within
>
the Mac's different environments. And if \n is meant to match all
>
styles of line ending, all I can say is that it's not worked that way
>
for me! I have a routine written some time ago which replaces all the
>
different styles of line endings with \r for just this reason.
Doesn't explain though why if I read it into a variable in the script from
a text file (where it'll presumably be \n already, since it just gets
written out of curl as "curl http.... > ~/Desktop/rankings.txt") it works,
but doesn't work if the variable is created directly from the curl result.
>
Depending on your needs, you could probably just modify the line ending
>
until you get what you want. I assume that curl doesn't modify line
>
endings for http traffic so you'd need to use the appropriate line
>
ending for the originating server:
As I said, it works already with \n in the search if read from a file. I'll
try it with \r, but changing all the line endings in a 132K file where I
only want about 10 characters is more hassle than it merits. Penalty of
screen-scraping, I guess, but I haven't found anywhere in the Amazon SDK
that shows how to get a product's sales ranking through the Amazon API.
Clues welcomed on that too.
Charles
--
-------------------------------------------------------------------
The Independent newspaper on the Web:
http://www.independent.co.uk/
It's even better on paper
______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit
http://www.messagelabs.com/email
______________________________________________________________________
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.