Skip to content

Instantly share code, notes, and snippets.

View tamimibrahim's full-sized avatar

Tamim Bin Ibrahim tamimibrahim

View GitHub Profile
@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');
@mickaelandrieu
mickaelandrieu / webservice.js
Created October 11, 2013 20:45
Use casperJs as a Webservice
/* from http://stackoverflow.com/questions/15852987/casperjs-passing-data-back-to-php/16489950#16489950
//define ip and port to web service
var ip_server = '127.0.0.1:8585';
//includes web server modules
var server = require('webserver').create();
//start web server
var service = server.listen(ip_server, function(request, response) {
var casper = require('casper').create({
verbose: true,
logLevel: 'debug',
pageSettings: {
userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.4 (KHTML, like Gecko) Chrome/22.0.1229.94 Safari/537.4'
}
});
var url = 'https://www.pinterest.com/login/';
IMPORTANT
Please duplicate this radar for a Safari fix!
This will clean up a 50-line workaround.
rdar://22376037 (https://openradar.appspot.com/radar?id=4965070979203072)
//////////////////////////////////////////////////////////////////////////////
(Now available as a standalone repo.)
@lsauer
lsauer / parseInt.py
Last active April 3, 2022 09:11
Python: JavaScript like parseInt function in one line
#lsauer.com, 2013
#Note: -)for convenience the function uses the re-module, but can be rewritten to fit into a lambda expression
# -)choose any other, more-expressive return type such as NumPy's `nan` over None if you like
#demonstrative-version:
def parseInt(sin):
import re
return int(''.join([c for c in re.split(r'[,.]',str(sin))[0] if c.isdigit()])) if re.match(r'\d+', str(sin), re.M) and not callable(sin) else None
#via a simple regex:
@clochix
clochix / casperCookies.js
Created July 10, 2013 16:48
Sample cookies management with CasperJS: functions to load cookies from a Netscape formatted file and save them
/**
* Load cookies from a file
*
* @param {String} file name of da file.
*
* @return {Array} of cookies.
*/
function loadCookies(file) {
"use strict";
var cookies = [];
@shuuheyhey
shuuheyhey / capture.js
Created May 20, 2013 22:51
casperjs > capture.js
var screenshotUrl = 'http://example.com/'
var casper = require("casper").create({
viewportSize: {
width: 1280,
height: 1280
}
});
if (casper.cli.args.length < 1) {
@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({
});
@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 {
@JeffreyWay
JeffreyWay / laravel.js
Last active April 6, 2024 20:12
Want to send a DELETE request when outside of a form? This will handle the form-creation bits for you dynamically, similar to the Rails implementation. (Requires jQuery, but doesn't have to.) To use, import script, and create a link with the `data-method="DELETE"` attribute.
/*
<a href="posts/2" data-method="delete"> <---- We want to send an HTTP DELETE request
- Or, request confirmation in the process -
<a href="posts/2" data-method="delete" data-confirm="Are you sure?">
*/
(function() {