Isolate text via the clipboard/textedit with"Get text from Webpage"

Here’s the deal. I want to isolate the a value from a HTML page , to be precise a setting in my router homepage. I use the Automator script “Get Specified URL’s” (http://speedtouch.lan/cgi/b/dsl/dt/?be=0&l0=1&l1=0) (Obviously that will resolve nothing for you unless you have Thomson Speedtouch router :wink: ) and I copy the text on the page using “Get text from Webpage” and copy it to the clipboard.

The text looks something on the clipboard looks something like this…


    THOMSON ST585v6sl                 

DSL Connection
Link InformationUptime:1 day, 4:27:21Modulation:G.992.1 annex ABandwidth (Up/Down) [kbps/kbps]:448 / 8,128Data Transferred (Sent/Received) [MB/MB]:11.29 / 218.13Output Power (Up/Down) [dBm]:11.5 / 19.5Line Attenuation (Up/Down) [dB]:16.0 / 25.0SN Margin (Up/Down) [dB]:25.0 / 11.5Vendor ID (Local/Remote):TMMB / ALCBLoss of Framing (Local/Remote):0 / 0Loss of Signal (Local/Remote):0 / 0Loss of Power (Local/Remote):0 / 0Loss of Link (Remote):0Error Seconds (Local/Remote):750 / 0FEC Errors (Up/Down):0 / 0CRC Errors (Up/Down):0 / 31,896HEC Errors (Up/Down):0 / 9,734


I want to grab just the values that follows :

SN Margin (Up/Down) [dB]

as two seperate values.

I have limitations.

I cannot use Excel. (Budget reasons)
I cannot appear to manipulate this paste in Filemaker Pro after it is pasted into a seperate field in a record.
Any ideas people?

Thanks

Martin

Hi Martin,

parsing text is quite easy with AppleScript’s text item delimiters


set a to "------------------------------------------------------------------------------------------------------------------------------------------------------------------

        THOMSON ST585v6sl                 

DSL Connection
Link InformationUptime:1 day, 4:27:21Modulation:G.992.1 annex ABandwidth (Up/Down) [kbps/kbps]:448 / 8,128Data Transferred (Sent/Received) [MB/MB]:11.29 / 218.13Output Power (Up/Down) [dBm]:11.5 / 19.5Line Attenuation (Up/Down) [dB]:16.0 / 25.0SN Margin (Up/Down) [dB]:25.0 / 11.5Vendor ID (Local/Remote):TMMB / ALCBLoss of Framing (Local/Remote):0 / 0Loss of Signal (Local/Remote):0 / 0Loss of Power (Local/Remote):0 / 0Loss of Link (Remote):0Error Seconds (Local/Remote):750 / 0FEC Errors (Up/Down):0 / 0CRC Errors (Up/Down):0 / 31,896HEC Errors (Up/Down):0 / 9,734

-------------------------------------------------------------------------------------------------------------------------------------------------------------------"
-- or:
-- set a to (get the clipboard)

set {TID, text item delimiters} to {text item delimiters, "SN Margin (Up/Down) [dB]:"}
set b to words 1 thru 2 of text item 2 of a
set text item delimiters to "Vendor"
tell b to set {Marginup, Margindown} to {its item 1, text item 1 of item 2}
set text item delimiters to TID
--> the two values are in Marginup and Margindown

Note: the “detour” using the clipboard is probably not necessary, if the text is stored into a variable

Moved out of Code Exchange

I’ve expected that much sooner.

just kidding :slight_smile:

Hi Stefan

I just wondered if you could (or anyone can) give me a pointer as to why the solution you offered did not isolate the specific text on the clipboard.

I’m using Automator to carry out the following workflow:

  1. Get specifed URLs

  2. Get Text from Webpage

  3. Copy to Clipboard

–Clipboard now contains the following:

    THOMSON ST585sl

(Bigger padded space here)

DSL Connection
Link InformationUptime:2 days, 23:43:33Modulation:G.992.1 annex ABandwidth (Up/Down) [kbps/kbps]:288 / 2,272Data Transferred (Sent/Received) [MB/MB]:7.63 / 60.13Output Power (Up/Down) [dBm]:11.0 / 15.0Line Attenuation (Up/Down) [dB]:16.5 / 26.0SN Margin (Up/Down) [dB]:31.0 / 30.5Vendor ID (Local/Remote):TMMB / TSTCLoss of Framing (Local/Remote):0 / 0Loss of Signal (Local/Remote):9 / 0Loss of Power (Local/Remote):0 / 0Loss of Link (Remote):0Error Seconds (Local/Remote):13 / 0FEC Errors (Up/Down):0 / 0CRC Errors (Up/Down):0 / 0HEC Errors (Up/Down):0 / 0

  1. Run Applescript --Inserted your script (I’ve tried both varieties)–

  2. New Text File

The file still contains all the contents of the clipboard, not just the values the Applescript is isolating. Any idea what I’m doing wrong here?

Thanks

Martin