Reading HTML code with batch file

Discussion in 'Scripting & Programming' started by Pheonicks56, May 25, 2011.

  1. Pheonicks56

    Pheonicks56 Kilobyte Poster

    Hi all long time no see. :biggrin

    I was wondering if y'all could help me with a project I'm working on. Here's the layout:

    We want a user to be able to run a batch file that allows them to input a website, then have the script open a browser, go to the site, copy a line from the html source code, and paste that back into the batch file to continue running commands.

    We have servers that have client software versions on their web sites that users need to use run commands to access properly, the correct version of the software is embedded in the source code, that's why we need that info.

    What would be the best way to go about coding this? VBscript, .bat, AutoIT?

    Thanks for any help!
    Certifications: BSIT, AAIT, A+
    WIP: Network+
  2. soundian

    soundian Gigabyte Poster

    Welcome back buddy!
    The hard bit is telling your script how to parse the website so it gets the right URL every time.
    Everything else is a piece of p*ss.
    Last edited: May 26, 2011
    Certifications: A+, N+,MCDST,MCTS(680), MCP(270, 271, 272), ITILv3F, CCENT
    WIP: Knuckling down at my new job
  3. Pheonicks56

    Pheonicks56 Kilobyte Poster

    So this is kind of what I have so far, the .bat asks the user for the server input.

    User inputs dach1, then the .bat launches IE.
    IE goes to http://dach1/

    On dach1 it says the version is Essentrisv3.49.0003.0006, which is a link to download that version of the software. How do I go about getting the .bat or anything for that matter to read the Essentrisv3.49.0003.0006 and then paste that back into the .bat as variable for a run command?

    If this can be done with a VBS or even AutoIT I'm all game, just curious.

    Thanks a ton for any help!
    Certifications: BSIT, AAIT, A+
    WIP: Network+
  4. dmarsh

    dmarsh Petabyte Poster

    You could use perl, python, VBscript or Powershell. Failing that use any general purpose full featured programming language (C\C++, VB, C#, Java, etc).

    Never heard of AutoIT, sounds like you could make it work by calling into the right Windows API or COM calls for the HTTP and XML DOM support.

    IE is way too bloated for your needs, you don't need page rendering, you don't need caching, cookies, yadda yadda. If you do use IE you have the added difficulty of working out the current cache directory for the current user and session.

    I'd use wget or a http client library to download the page.

    Then something like HTML Tidy (this is C version, its been ported as a native lib in many languages).

    Then I'd use an XPATH (and possibly XSLT, XML parser/DOM) depending on details.

    If you control the design of the web server part then you can implement whatever distributed communications you like, you don't need HTML per see. The most obvious idea would be to use REST and map the read URL action to a HTTP GET request on a URI. Theres no need for 'links', you can format the response how you wish, although JSON would be an obvious choice.

    I'm not big on scripting in general, tend to just go C#, Java, or C++ as it gives me full control.

    Powershell looks quite straightforward once you get the syntax though...
    Last edited: May 26, 2011
  5. Pheonicks56

    Pheonicks56 Kilobyte Poster

    Thanks Dmarsh,

    That's a lot of reading, I'll have to look at this today. I've never done much programming, a little Java in school, which was aweful because it was accelerated and I'm not a natural. So I'll work on this and let ya know what I come up with.
    Certifications: BSIT, AAIT, A+
    WIP: Network+

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.