Which is the correct language

Discussion in 'Mac Programming' started by castingflame, Dec 1, 2009.

  1. castingflame macrumors newbie

    Joined:
    Dec 1, 2009
    #1
    Hello everyone

    I wish to Launch Firefox with a certain profile. Read some of the text on the web page. When certain html text conditions are correct quit Firefox then start all over with a different Firefox profile.

    Which is the best Language for this type of operation on OSX.

    I would prefer to use one language to achieve this. I have been using Applescript and cron to start and kill the browser sessions but as I can not read the screen quiting or killing the session is guess work.

    I had some experience with Perl/Active Perl a few years back. Would this be a good choice?

    Kind Reagrds

    Paul
     
  2. skunkworker macrumors regular

    Joined:
    Sep 9, 2007
    #2
    What do you mean 'profile' ?
    Why not just write a firefox extension to do this?
     
  3. jpyc7 macrumors 6502

    Joined:
    Mar 8, 2009
    Location:
    Denver, CO
    #3
    Based on your desire to read the website html, you have 2 general options.
    1. Download the web page with a simple HTTP client such as "wget" or using a scripting language that has an HTTP client capability. I'm sure Perl has that capability and so does Python.
    2. Write a Firefox plugin that initiates the download of the website. I believe the language here is Javascript.

    The difference between the two choices is that the Firefox plugin has access to the capabilities of Firefox such as Javascript execution. So if the website has dynamic elements written in Javascript which lead to more object downloads, then the Firefox plugin will have access to such downloads. Depending on what you are looking for in the website, the Firefox plugin architecture might provide the type of parsing you need automatically, e.g. return the number of DOM elements.

    If you don't need the power of Firefox in the initial download, then I think the first approach is probably going to be quicker for implementation. You don't need to learn the whole Firefox plugin architecture, xpi packaging, and API.

    If this is a long-term project where you might keep adding functionality, I think a plugin will be more powerful, but it does involve a steeper learning curve.

    In either case, you'll need one scripting language to initiate the Firefox and I think it is mostly a personal preference on what to use. I'm sure that Perl is powerful enough. Personally, I don't like its syntax but I can't deny that it has a large user base and lots of libraries.
     

Share This Page