URL Extraction from String with Applescript

Discussion in 'Mac Programming' started by mooty, Mar 7, 2006.

  1. macrumors regular

    Joined:
    Mar 7, 2006
    Location:
    UK
    #1
    Hi All,

    I want to extract an url, or number of urls from a string using applescript, and then set them to items in a list/array

    Is this possible?

    Thx for any help! :)
     
  2. macrumors G4

    Eraserhead

    Joined:
    Nov 3, 2005
    Location:
    UK
    #2
    yeah should be possible but it depends on how are you getting the url's?

    are they saved in a text file?
    if so how is the text formatted? (eg space's in between, a new line for each url?)
    or are you getting them from safari or camino directly?
     
  3. thread starter macrumors regular

    Joined:
    Mar 7, 2006
    Location:
    UK
    #3
    it would be from a URL probably - ie an html file most likely. Let say that the url is hard coded in the applescript - and the script reads the html from that...

    Thanks.
     
  4. macrumors G4

    Eraserhead

    Joined:
    Nov 3, 2005
    Location:
    UK
    #4
    OK I have made a simple applescript, I have read in some URL's from a text file (with the script), they are seperated by spaces. I hope it's useful. View attachment applescript.zip

    This will work with any list of URL's (without spaces in them) seperated by spaces.
     
  5. thread starter macrumors regular

    Joined:
    Mar 7, 2006
    Location:
    UK
    #5
    wow thanks for your efforts. i'll give it a whirl when i get home tonight and report back :) :)

    Thank you!
     
  6. macrumors G4

    Eraserhead

    Joined:
    Nov 3, 2005
    Location:
    UK
    #6
    no problem...;)
     
  7. thread starter macrumors regular

    Joined:
    Mar 7, 2006
    Location:
    UK
    #7
    Hi thanks for that - but is there a way to actually get urls from within HTML ? for example pick out all strings that start http:// etc ?
     
  8. macrumors G4

    Eraserhead

    Joined:
    Nov 3, 2005
    Location:
    UK
    #8

Share This Page