Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <h3>Using JavaScript with a headless browser</h3> <p>If you need to execute JavaScript, it will be easier if you have a JavaScript engine available.</p> <p>Instead of Python, I would consider using a headless browser such as <a href="http://phantomjs.org/" rel="nofollow">PhantomJS</a>. Then you can scrape the page and execute any JavaScript you need to, either running your own JS or code from the page itself.</p> <p>The <a href="https://github.com/ariya/phantomjs/wiki/Examples" rel="nofollow">examples page</a> for PhantomJS has several examples in the Page Automation section that may be similar to what you need.</p> <p>It looks like you want to run an existing function in the page: <code>WebForm_DoPostBackWithOptions()</code>. So I would take a look at the <a href="https://github.com/ariya/phantomjs/blob/master/examples/injectme.js" rel="nofollow">injectme.js</a> example which injects a script into the page. That script could then in turn call any function in the page you want to.</p> <p>Or depending on what you're doing, there may be an even simpler way to do it with PhantomJS. They have a lot of good examples and docs to look through.</p> <h3>Using Python and a JavaScript debugger</h3> <p>Of course, you may not actually need to directly <em>execute</em> the <code>WebForm_DoPostBackWithOptions()</code> function. From the name, that sounds like it's likely to be a fairly simple JavaScript function. Have you looked at its code and traced through it while interacting with the page manually in a web browser? Tracing through the code should make it easy to see what the function really does. (If you do that in the Chrome developer tools and find that the code is unreadable because it's been "minified", use the <code>{}</code> button to pretty-print it.)</p> <p>Or to cut to the chase, the Network tab or equivalent in any of the browser debuggers should let you see exactly what <code>POST</code> request is generated by that function. Then you can do the same in your Python code.</p> <p>If you're not familiar with the developer tools in the current browsers, you are in for a treat: they are really good these days. I like the one built into Chrome, but Firebug (for Firefox) and the Internet Explorer tools are also excellent.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload