Pavel Tyslacki
just execute without DOM and other standard browser APIs
>>> import execjs
>>> print(execjs.eval('[1, 2, 4].indexOf(4)'))
2
>>> print(execjs.eval('[1, 2, 4].indexOf(3)'))
-1
JS task manager or build system
var gulp = require('gulp'),
eslint = require('gulp-eslint'),
qunit = require('gulp-qunit');
gulp.task('lint', function () {
gulp.src('./tests.js')
.pipe(eslint({
rules: {'quotes': 1}, globals: {'QUnit': 1}, env: {browser: 1}
}))
.pipe(eslint.format());
});
gulp.task('test', function () {
return gulp.src('./tests.html')
.pipe(qunit());
});
web browser module for python
based on pyqt webkit
import spynner
browser = spynner.Browser()
browser.load('http://www.python.org/')
browser.snapshot().save('file.png')
browser.close()
headless webkit scriptable with JS API
login to python.org and go to public profile
from selenium import webdriver
driver = webdriver.Firefox()
driver.get('https://www.python.org/accounts/login/')
driver.find_element_by_id('id_login').send_keys('user')
driver.find_element_by_id('id_password').send_keys('password')
driver.find_element_by_css_selector('.primaryAction').click()
feblt = driver.find_element_by_link_text
action = webdriver.ActionChains(driver)
action.move_to_element(feblt('Sign Out')).perform()
driver.implicitly_wait(0.5)
action.move_to_element(feblt('View your public profile')).perform()
action.click().perform()
driver.quit()
pisa based - works bad
no wkhtmltoimage :(
measuring and analyzing the performance of web pages
instances on windows only :(
capture performance data from browsers
from browsermobproxy import Server
server = Server('path/to/browsermob-proxy')
server.start()
proxy = server.create_proxy()
from selenium import webdriver
profile = webdriver.FirefoxProfile()
profile.set_proxy(proxy.selenium_proxy())
driver = webdriver.Firefox(firefox_profile=profile)
proxy.new_har('python')
driver.get('http://www.google.co.uk')
proxy.har # returns a HAR JSON blob
server.stop()
driver.quit()
JS rendering service with HTTP API
runs on top of twisted and pyqt webkit
$ python -m splash.server
$ curl 'http://localhost:8050/render.html?url=http://domain.com/page-with-javascript.html&timeout=10&wait=0.5'
tab and inline hell
<html>
<style type="text/css">
h1 { border:1px solid black }
p { color:red;}
</style>
<h1 style="font-weight:bolder">Peter</h1>
<p>Hej</p>
</html>
<html>
<h1 style="font-weight:bolder; border:1px solid black">Peter</h1>
<p style="color:red">Hej</p>
</html>
pavel.tyslyatsky@gmail.com