Can someone provide a script for me?

Discussion in 'Mac Programming' started by pperiklis, Oct 12, 2007.

  1. pperiklis macrumors newbie

    Joined:
    Oct 12, 2007
    #1
    I need to use a webpage every time I want to translate a word from english to greek. I found out that instead of using the search command on the page I can just type http://www.in.gr/dictionary/lookup.asp?Word=unknown&x=0&y=0 in the address bar and replace the word unknown with the one I want to translate.
    My question is: Can someone provide me with a script in which I can give just the word and get the results from the webpage "sherlock style"?
    P.S. I know that sherlock already does translate from english to greek but the translations are quite poor.
     
  2. harisdmac macrumors member

    Joined:
    Aug 16, 2006
    #2
    Try using Javascript within your html code, or php (if its supported by your server).
    There are plenty examples on net on how to invoke urls with parameters and parse the generated html code.
    However, Keep in mind that special copyrights might apply for the usage of the in.gr dictionary.
     
  3. xUKHCx Administrator emeritus

    xUKHCx

    Joined:
    Jan 15, 2006
    Location:
    The Kop
    #3
    I thought the OP was asking for an applescript or something similar that they could run when they wanted to translate a word for personal use.
     
  4. toddburch macrumors 6502a

    Joined:
    Dec 4, 2006
    Location:
    Katy, Texas
    #4
    Can you explain "sherlock style?" (descriptively and pictorially)

    Todd
     
  5. pperiklis thread starter macrumors newbie

    Joined:
    Oct 12, 2007
    #5
    I have no intension on violating copyrights. I just want a script that will do the exact same job as the web page while I'm connected to the internet. By sherlock style I mean that it will be like a small window divided in 2 sections which I can keep open during the time I write what I want in Pages so that I don' t go back and forth whenever I need to translate a word. I wish I could do it myself but I don' t have the skills or the time to learn how.
     
  6. bbarnhart macrumors 6502a

    bbarnhart

    Joined:
    Jan 16, 2002
    Location:
    Stilwell, Kansas
    #6
    Regardless of laws and copyrights and other bad things, you will need an application or a HTML server or something to process the results from the translation server. Easiest thing would be a HTML server either locally on your box or on your iWeb ("I'm on ur iWEbz, tranzlatn yur Eglish")

    I can't think of a way to run a JavaScript in a browser by loading the file. If this can be overcome, it would be a fairly easy task to create a page with three things

    1 English text box for word
    2 Button to press
    3 Box to receive the resulting translation
     
  7. pperiklis thread starter macrumors newbie

    Joined:
    Oct 12, 2007
  8. toddburch macrumors 6502a

    Joined:
    Dec 4, 2006
    Location:
    Katy, Texas
    #8
    Here's a bookmarklet, maybe it will speed you up.

    Code:
    javascript: window.location="http://www.in.gr/dictionary/lookup.asp?Word="+prompt("Enter a word");
    
    Copy the above into the clipboard. Create a new bookmark on your Bar (I'll assume you are using Safari). Give the bookmark a name, like "Translate to Greek" and then paste the above javascript code as the address. (It will look like the data wasn't pasted, but if you CMD+left arrow, you'll see it there, and you'll also see Safari added %20 codes for all the blanks.)

    Close the bookmark editor. When you click the link, you'll get a window prompt to enter the word you want translated. When you click OK, it will take you to the website with the word you want already appended to the URL. The efficiency you will get from this is the word you want will be on the webpage on the your first display. No more going to the page, entering the word, and then waiting to have the page reload.

    If that web site structured their output document a little better (like if they gave the particular <table> you wanted an "id=.." attribute, parsing it to redisplay in a more succinct manner would have been fairly easy. As it is now, any parsing applied to that document would probably fail the first time they changed anything in its layout. (well, maybe not that dramatic, but it would be very prone to fail)

    Perhaps this will be a good compromise between what you asked for ( a lot ) and what I'm giving you.

    Todd
     
  9. toddburch macrumors 6502a

    Joined:
    Dec 4, 2006
    Location:
    Katy, Texas
    #9
    I was just reading up on (learning about) Sticky Notes. Pretty cool facility.

    If Pages and Sticky Notes were scriptable (and they probably are with AppleScript), this might be a nice flow:

    Highlight (select) a word in Pages. Right click on the word to send the selection to a script (visualize Windows Explorer, where it allows you to customize its right click context menu). The script would then build the url and read the page output (I'm visualizing a Ruby script with an open-uri call).

    Then, the script parses the html, sucks out the table data, and then calls Sticky Notes to display the parsed data.

    That would be very slick.

    Todd
     
  10. pperiklis thread starter macrumors newbie

    Joined:
    Oct 12, 2007
    #10
    Todd, I couldn' t thank you enough!

    "Perhaps this will be a good compromise between what you asked for ( a lot ) and what I'm giving you"

    You are absolutely right on that also. This made my search a lot faster.

    If what you are suggesting in your second post is possible, that would be even greater!
     
  11. toddburch macrumors 6502a

    Joined:
    Dec 4, 2006
    Location:
    Katy, Texas
    #11

Share This Page