Hi All,
Could I impose on someone to explain this line to me? Or at least point me in the right direction?
set theTxt to quoted form of (do shell script "curl '" & theURL & "' | egrep -A 17 'Full Address in Standard Format' | egrep -A 13 'height=\"34\"' | strings" without altering line endings)
I've Googled for the past 2 days and I can't decipher it for the life of me. I'm trying to pull some lines of text from the returned HTML. It works on the usps.com page it was written for, but I'd like to understand it so I can convert it to work with other pages as well.
These are some of the questions I have:
• Why are there two egrep commands? • What does -A 17 and -A 13 mean? • Are the pipes actually being used to pipe the lines, or do they just mean "or" in this situation? • What does "strings" mean?
Here is the full script I found:
set theTxt to quoted form of (do shell script "curl '" & theURL & "' | egrep -A 17 'Full Address in Standard Format' | egrep -A 13 'height=\"34\"' | strings" without altering line endings)
set _street to (do shell script "echo -n " & theTxt & " | sed -n 2p | cut -d'<' -f 1")
set _csz to quoted form of (do shell script "echo " & theTxt & " | sed -n 3p | tr -d '\r\n' " without altering line endings) set _city to (do shell script "echo " & _csz & " | cut -d'&' -f1") set _state to (do shell script "echo " & _csz & " | cut -d';' -f2 | cut -c 1-2")
set _zipBoth to quoted form of (do shell script "echo " & _csz & " | cut -d';' -f4") set _zip to (do shell script "echo " & _zipBoth & " | cut -c 1-5") set _zip4 to (do shell script "echo " & _zipBoth & " | cut -c 7-")
Would there be a better way to write this code, or is it pretty good already?
Thanks! Marc |