• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
strange behaviour in search for \n
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

strange behaviour in search for \n


  • Subject: strange behaviour in search for \n
  • From: Charles Arthur <email@hidden>
  • Date: Thu, 1 Jul 2004 10:52:53 +0100

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>

where XXXXX is the rank and \n is ASCII char 10. (The length of the ranking
number doesn't matter because I've got a TID routine that will find the
text between two given bits of text.) In Script Editor, \n gets converted
to a LF on the screen.

It works if I put the curl output into a text file, then read that file
into a variable in the script -> run the TID routine on the script. That
gives the rank number, nice and clean - no \n before or after.

However if (in order not to have a dummy file that I write and read) I
include the curl command as part of "do shell script" and put the output
straight into a variable in the script, and then search using "</b>\n" and
"\n</font>" as the start and end points, it fails. I get an empty list for
the output of the search - my subroutine's way of saying "no such thing
here".

BUT: if I use do shell script -> straight to variable in script -> search
begins at "</b>" and ends at "</font>" then it works - I get the ranking,
*preceded_and_followed_by* \n.

I can post the script here, but wondered if anyone could see anything
obvious that's wrong with what I'm doing. As I said, the "extract text"
subroutine works fine when I read the file in, so it's not a problem per se
with \n.

Charles
--
----------------------------
http://www.ukclimbing.com : 1200+ British crags, 350+ British climbing
walls - searchable by distance and anything else you care to think of -
with weather forecasts for every one, plus maps, articles, news and
features.

______________________________________________________________________
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.


  • Follow-Ups:
    • Re: strange behaviour in search for \n
      • From: Nigel Smith <email@hidden>
    • Re: strange behaviour in search for \n
      • From: Simon Forster <email@hidden>
  • Prev by Date: Script Menu coolfiguration
  • Next by Date: Re: Sum of list?
  • Previous by thread: Script Menu coolfiguration
  • Next by thread: Re: strange behaviour in search for \n
  • Index(es):
    • Date
    • Thread