Skip to content

Instantly share code, notes, and snippets.

View screeley's full-sized avatar

Sean Creeley screeley

View GitHub Profile
"""
Copyright (c) 2009, Sean Creeley
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
#
# Script From: http://blog.davidziegler.net/post/122176962/a-python-script-to-automatically-extract-excerpts-from
#
# "http://www.sfgate.com/cgi-bin/article.cgi?f=/c/a/2009/06/04/DD7V1806SV.DTL&type=performance"
Opera review: 'Tosca' arias pulsate : Close [X]Quick links to the best of SFGate | Still can't find it? see Site Index
# "http://www.chloeveltman.com/blog/2009/05/two-very-different-symphonies.html#links",
lies like truth: Two Very Different Symphonies : The diversity of the Bay Area can be witnessed in many different ways, from the variety of the cuisine offered in its restaurants to the multitudinous kinds of topography. One less obvious way to explore the radical differences that coexist in this part o
"""
A script for automatically extracting excerpts from articles. It requires lxml.
Usage::
from lxml_extractor import get_summary
url = "http://someurl.com/goes/here"
(title,description) = get_summary(url)
import re
import urllib
import urllib2
# JSON decoder
try:
import json
except ImportError:
try:
import simplejson as json
<div class="vodpod_player">
<embed src="http://www.youtube.com/v/3fmw01mAvkw&fs=1&showinfo=0&showsearch=0&rel=0&hl=en_US"
type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true"
wmode="opaque" width="400" height="320"></embed>
<img src="http://stats.vodpod.com/stats/view/7619747/518458/4056/pod.gif" width="1"
height="1" style="margin:0 -1px -1px 0;border:none;padding:0;display:inline;">
<img src="http://s.vodpod.com/stats/video/4959049/1//KW2iDoVtAYHDGaSEr0V+sDZPO+hOc3+ZxmYyDp4t4Iw="
width="1" height="1" style="margin:0 -1px -1px 0;border:none;padding:0;display:inline;">
</div>
@screeley
screeley / gist:957841
Created May 5, 2011 20:21
OAuth Embedly
import oauth2 as oauth
import time
import urllib, urllib2
# Set the API endpoint
url = "http://pro.embed.ly/1/preview"
urls = ['http://google.com', 'http://apple.com']
params = {
@screeley
screeley / change_user_agents.py
Created May 31, 2011 20:02
Change.org is changing responses for Facebook and Google
## Change.org. We are going to start using facebook's user-agent. FYI.
In [1]: import urllib2
In [2]: req = urllib2.Request('http://www.change.org/petitions/boston-red-sox-please-make-an-it-gets-better-video')
#Embedly's User Agent
In [3]: req.add_header('User-Agent', 'Mozilla/5.0 (compatible; Embedly/0.2; +http://support.embed.ly/)')
In [4]: urllib2.urlopen(req).read()
#Random HTML that sets cookies
Out[4]: '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><meta http-equiv="Content-Script-Type" content="text/javascript"><script type="text/javascript">function setCookie(c_name, value, expiredays) { var exdate = new Date(); exdate.setDate(exdate.getDate()+expiredays); document.cookie = c_name + "=" + escape(value) + ((expiredays==null) ? "" : ";expires=" + exdate.toGMTString()) + ";path=/"; } function getHostUri() { var loc = document.location; return loc.toString(); } setCookie(\'YPF8
@screeley
screeley / form.html
Created August 9, 2011 16:00
Creating a Facebook-like URL submission tool with Embedly (Html)
<form action="." method="post">
<textarea id="id_status" name="status">
</textarea>
<input type="submit" value="Save"/>
</form>
#!/usr/bin/env python
"""Proxy"""
import urllib
import json
import tornado.httpserver
import tornado.ioloop
import tornado.web
import tornado.wsgi
import tornado.httpclient
import time
import functools
import tornado.httpserver
import tornado.ioloop
import tornado.web
import tornado.wsgi
import tornado.httpclient