getting a value from a web-page

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Alberto Vera

    getting a value from a web-page

    Hello:

    Is it possible to get a row from a text-file? This text-file is located in a web page.
    And a value from an excel located in a web-server? (Sheet1!cell A1)

    Regards
  • Mark Carter

    #2
    Re: getting a value from a web-page

    > Is it possible to get a row from a text-file? This text-file is located[color=blue]
    > in a web page.[/color]

    I'm not sure exactly what it is you are trying to achieve, but you
    might be able to use the urllib() module to download the file. I
    recall the existence of a module which can efficiently extract
    specified rows from a text file - but, alas, I don't recall its name.
    But it wouldn't be strictly necessary, anyway.
    [color=blue]
    > And a value from an excel located in a web-server? (Sheet1!cell A1)[/color]

    Do you mean an excel file located on your server, or somebody else's
    server? If it is on your server, you could manipulate the file
    directly using Mark Hammond's excellent win32all:


    A typical piece of python code to manipulate Excel is:

    # this example starts Excel, creates a new workbook,
    # puts some text in the first and second cell
    # closes the workbook without saving the changes
    # and closes Excel. This happens really fast, so
    # you may want to comment out some lines and add them
    # back in one at a time ... or do the commands interactively


    from win32com.client import Dispatch


    xlApp = Dispatch("Excel .Application")
    xlApp.Visible = 1
    xlApp.Workbooks .Add()
    xlApp.ActiveShe et.Cells(1,1).V alue = 'Python Rules!'
    xlApp.ActiveWor kbook.ActiveShe et.Cells(1,2).V alue = 'Python Rules 2!'
    xlApp.Close(Sav eChanges=0)
    xlApp.Quit()
    del xlApp

    # raw_input("pres s Enter ...")

    Comment

    • Xavier Martínez

      #3
      Re: getting a value from a web-page

      > > Is it possible to get a row from a text-file? This text-file is located[color=blue][color=green]
      > > in a web page.[/color]
      >
      > I'm not sure exactly what it is you are trying to achieve, but you
      > might be able to use the urllib() module to download the file. I
      > recall the existence of a module which can efficiently extract
      > specified rows from a text file - but, alas, I don't recall its name.
      > But it wouldn't be strictly necessary, anyway.[/color]

      Have a look at 'linecache' module. This will only work with a
      local file, though, so you need to retrieve the file, see
      urllib.urlretri eve() at:



      See also:

      and:
      http://gnosis.cx/TPiP/chap1.txt (a chapter of David Mertz's book
      'Text Processing in Python').


      Comment

      • Gerrit Holl

        #4
        Re: getting a value from a web-page

        Mark Carter wrote:[color=blue][color=green]
        > > And a value from an excel located in a web-server? (Sheet1!cell A1)[/color]
        >
        > Do you mean an excel file located on your server, or somebody else's
        > server? If it is on your server, you could manipulate the file
        > directly using Mark Hammond's excellent win32all:
        > http://starship.python.net/crew/mhammond/[/color]

        Is it possible to do so without Windows?

        Gerrit.

        --
        173. If this woman bear sons to her second husband, in the place to
        which she went, and then die, her earlier and later sons shall divide the
        dowry between them.
        -- 1780 BC, Hammurabi, Code of Law
        --
        Asperger Syndroom - een persoonlijke benadering:

        Het zijn tijden om je zelf met politiek te bemoeien:
        De website van de Socialistische Partij (SP) in Nederland: Informatie, nieuws, agenda en publicaties.


        Comment

        • Alex Martelli

          #5
          Re: getting a value from a web-page

          Gerrit Holl wrote:
          [color=blue]
          > Mark Carter wrote:[color=green][color=darkred]
          >> > And a value from an excel located in a web-server? (Sheet1!cell A1)[/color]
          >>
          >> Do you mean an excel file located on your server, or somebody else's
          >> server? If it is on your server, you could manipulate the file
          >> directly using Mark Hammond's excellent win32all:
          >> http://starship.python.net/crew/mhammond/[/color]
          >
          > Is it possible to do so without Windows?[/color]

          No, win32all only runs on Windows (perhaps it might be ported to
          WINE or something, but I know of nothing like that ever being done).
          Microsoft Excel can run just fine on Linux thanks to "Crossover
          Office" (or, presumably, other versions of Wine, too), but I do
          not know how to "programmatical ly" drive it from Python under
          such environments.

          One possibility might be to use OpenOffice 1.1 (which is able to
          open and read XLS files, and can in turn be driven by Python with
          the new "Python-UNO bridge" included in OO release 1.1) -- but I
          have, as yet, no practical experience doing that.


          Alex

          Comment

          Working...