Last active
July 27, 2016 05:45
-
-
Save orleika/49ac310531d1e2ce77dcfdf3ccb562e3 to your computer and use it in GitHub Desktop.
Running Browser environment on Node.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Requirements | |
Python | |
`$ npm install -g phantomjs` | |
`$ npm install -g casperjs` | |
## Run | |
`$ casperjs index.js` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Test page</title> | |
</head> | |
<body> | |
<script src="main.js"></script> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var casper = require('casper').create(); | |
casper.start('./index.html'); | |
casper.then(function() { | |
this.echo(this.getHTML()); | |
}); | |
casper.run(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
/** | |
* Do somethings | |
*/ | |
var script = document.createElement('script'); | |
script.src = 'another.js'; | |
document.getElementsByTagName('head')[0].appendChild(script); | |
}()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "browser-access", | |
"main": "index.js", | |
"dependencies": { | |
"casperjs": "^1.1.3" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment