Skip to content

Instantly share code, notes, and snippets.

View tamimibrahim's full-sized avatar

Tamim Bin Ibrahim tamimibrahim

View GitHub Profile
@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];
@jonathonbyrdziak
jonathonbyrdziak / example.php
Created February 22, 2012 02:27
Wordpress Metabox, stand alone class for multiple metabox abilities
<?php
/*
Here's a couple of metaboxes that I've recently created using this system
*/
$subpostings = redrokk_metabox_class::getInstance('subpostings', array(
'title' => '(optional) Subscription for Postings',
'description' => "As an optional feature, you have a complete api at your disposal which will allow you the ability to offer and manage member posts. In addition to these settings, you may need to create the associated pages for accepting posts from your frontend.",
@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(){
@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
@zhangyuan
zhangyuan / gist:7037980
Last active November 9, 2020 06:44
Scrap pages generated by javascript with casperjs
// http://casperjs.org/
var casper = require('casper').create({
pageSettings: {
loadImages: false,
}
});
var fs = require('fs');
@LeCoupa
LeCoupa / fake-referer.casper.coffee
Last active October 21, 2020 10:43 — forked from papoms/fake-referrer.casper.js
How to fake the HTTP referer with CasperJS --> https://github.com/LeCoupa/awesome-cheatsheets
# Define Variables + Casper Initialization
fakeReferer = 'https://google.com/'
targetUrl = 'https://facebook.com/'
casper = require('casper').create()
# Fake the referer
casper.start fakeReferer, ->
@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
*/
@tareq1988
tareq1988 / settings-api-class-demo.php
Created March 8, 2013 13:46
A simple theme options page created with WordPress Settings API PHP class https://github.com/tareq1988/wordpress-settings-api-class
<?php
require_once dirname( __FILE__ ) . '/class.settings-api.php';
/**
* Theme Admin panel for Tareq's Planet
*
* @author Tareq Hasan
*/
class Tareqs_Planet_Admin {
@imjared
imjared / scraping-with-casperjs.js
Created March 20, 2013 00:33
A CasperJS script that crawled a list of links on then scraped the relevant content on each page and output it to a nicely formatted XML file. Sure beats database dumps/SQL manipulation, in my opinion.
/*jshint strict:false*/
/*global CasperError console phantom require*/
/**
* grab links and push them into xml
*/
var casper = require("casper").create({
});
@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);
});
});