Skip to content

Instantly share code, notes, and snippets.

View tamimibrahim's full-sized avatar

Tamim Bin Ibrahim tamimibrahim

View GitHub Profile
@bshamric
bshamric / cache.js
Last active January 24, 2021 12:08
I like phantomjs, but it doesn't directly support getting images from webpages without requesting them separately like in casperjs. I went through QTNetworking code in the phantomjs repo until I figured out where the cache was. To use this, have all three files in the same directory. Then modify test.js for whatever you need. Call phantom js wit…
var fs = require('fs');
//this is the path that QTNetwork classes uses for caching files for it's http client
//the path should be the one that has 16 folders labeled 0,1,2,3,...,F
exports.cachePath = '/path/to/phantomjs/cache/data/folder';
//this is the extension used for files in the cache path
exports.cacheExtension = "d";
//the resources that are to be saved
@brunobord
brunobord / kill.js
Created January 30, 2013 23:21
Casper Script: restart Alwaysdata processes.
/**
* Casper script to restart Alwaysdata processes.
*
* Usage:
* $ casperjs kill.js email@example.com mysecretpassword
*/
var casper = require('casper').create();
casper.start("https://admin.alwaysdata.com/login/");
@ganglio
ganglio / fb.js
Created December 13, 2012 14:39
CasperJS: Facebook photos scraper
var casper = require('casper').create({
verbose : true,
logLevel : 'info'
});
var images = [];
var fs=require("fs")
/**
* Configuration here
*/
@ikstob
ikstob / AddMeFastExample.java
Created November 19, 2012 19:38
Example of using Selenium from Java
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.ExpectedCondition;
@nhoizey
nhoizey / screenshots.js
Created November 12, 2012 17:07
Take screenshots at different viewport sizes using CasperJS
/*
* Takes provided URL passed as argument and make screenshots of this page with several viewport sizes.
* These viewport sizes are arbitrary, taken from iPhone & iPad specs, modify the array as needed
*
* Usage:
* $ casperjs screenshots.js http://example.com
*/
var casper = require("casper").create();
@papoms
papoms / fake-referrer.casper.js
Created August 24, 2012 16:10
Fake Referrer with CasperJS
var fakeReferrer = "http://porzky.com"
var targetUrl = "http://keyworddomains.com"
var casper = require('casper').create();
casper.start(fakeReferrer, function() {
this.echo(this.getCurrentUrl());
});
casper.then(function(){
@jonaslund
jonaslund / fbScrape.js
Created August 15, 2012 10:18
Casperjs script to screenshot an entire Facebook Post
// Using Casperjs to screenshot an entire Facebook Post */
var casper = require('casper').create({
clientScripts: [
'jquery.js'
]
});
//login to facebook
casper.start('https://www.facebook.com/', function() {
this.fill('#login_form', { email: 'email', pass: 'password' }, true);
@subelsky
subelsky / casperjs_example.js
Created August 8, 2012 18:51
Webscraping with CasperJS, PhantomJS, jQuery, and XPath
var system = require('system');
if (system.args.length < 5) {
console.info("You need to pass in account name, username, password, and path to casperJS as arguments to this code.");
phantom.exit();
}
var account = system.args[1];
var username = system.args[2];
var password = system.args[3];
@iwek
iwek / cookies.js
Created July 17, 2012 14:31
view and disable cookies in casperjs and phantomjs
//to disable cookies, run casperjs --cookies-file=/dev/null? cookies.js
var casper = require('casper').create();
casper.start('http://wordpress.org/', function() {
this.echo('Browser Cookie: ' + this.evaluate(function() {
return document.cookie;
}));
});
@thom4parisot
thom4parisot / casper-dump-headers.js
Created July 17, 2012 13:58
Dump Response Headers with CasperJS
var casper = require('casper').create();
casper.start();
casper.open('http://borisschapira.com/');
casper.then(function dumpHeaders(){
this.currentResponse.headers.forEach(function(header){
console.log(header.name +': '+ header.value);
});
});