Evaluate javascript on a local html file (without browser)

前端 未结 2 1922
猫巷女王i
猫巷女王i 2020-12-11 13:02

This is part of a project I am working on for work.

I want to automate a Sharepoint site, specifically to pull data out of a database that I and my coworkers only ha

相关标签:
2条回答
  • 2020-12-11 13:45

    Well, in the end I came down to the following possible solutions:

    • Run Chrome headless and collect the html output (thanks to koenp for the link!)
    • Run PhantomJS, a headless browser with a javascript api
    • Run HTMLUnit; same thing but for Java
    • Use Ghost.py, a python-based headless browser (that I haven't seen suggested anyyyywhere for some reason!)
    • Write a DOM-based javascript interpreter based on Pyv8 (Google v8 javascript engine) and add this to my current "half-solution" with mechanize.

    For now, I have decided to use either use Ghost.py or my own modification of the PySide/PyQT Webkit (how ghost works) to evaluate the javascript, as apparently they can run quite fast if you optimize them to not download images and disable the GUI.

    Hopefully others will find this list useful!

    0 讨论(0)
  • 2020-12-11 13:55

    Well you will need something that both understands the DOM and understand Javascript, so that comes down to a headless browser of some sort. Maybe you can take a look at the selenium webdriver, but I guess you already did that. I don't hink there is an easy way of doing this without running the stuff in an actually browser engine.

    0 讨论(0)
提交回复
热议问题