Freedom for Our Files: Code and Slides

A two-day workshop, with both technical hands-on and idea-driven components. Learn to scrape data and reuse public and private information by writing custom code and using the Facebook API. Additionally, we’ll converse and conceptualize ideas to reclaim our data literally and also imagine what is possible with our data once it is ours!

Here are the slides and some of the code samples from the Freedom for Our Files (FFOF) workshop I just did in Linz at Art Meets Radical Openness (LiWoLi 2011).

The first one is a basic scraping demo that uses “find-replace” parsing to change specific words (I’m including examples below the code)

<?php

/*	Basic scraping demo with "find-replace" parsing
 *	Owen Mundy Copyright 2011 GNU/GPL */

$url = "http://www.bbc.co.uk/news/";	// 0. url to start with

$contents = file_get_contents($url);	// 1. get contents of page in a string

					// 2. search and replace contents
$contents = str_replace(		// str_replace(search, replace, string)
			"News",					
			"<b style='background:yellow; color:#000; padding:2px'>LIES</b>",
			$contents);

print $contents;			// 3. print result

?>

Basic scraping demo with “foreach” parsing

<?php

/*	Basic scraping demo with "foreach" parsing
 *	Owen Mundy Copyright 2011 GNU/GPL */
 
$url = "http://www.bbc.co.uk/news/";	// 0. url to start with

$lines = file($url);			// 1. get contents of url in an array

foreach ($lines as $line_num => $line) 	// 2. loop through each line in page
{		
					// 3. if opening string is found
	if(strpos($line, '<h2 class="top-story-header ">')) 	
	{
		$get_content = true;	// 4. we can start getting content
	}
	
	if($get_content == true)
	{
		$data .= $line . "\n";	// 5. then store content until closing string appears
	}

	if(strpos($line, "</h2>")) 	// 6. if closing HTML element found
	{
		$get_content = false;	// 7. stop getting content
	}
}

print $data;				// 8. print result

?>

Basic scraping demo with “regex” parsing

<?php

/*	Basic scraping demo with "regex" parsing
 *	Owen Mundy Copyright 2011 GNU/GPL */
 
$url = "http://www.bbc.co.uk/news/";		// 0. url to start with

$contents = file_get_contents($url);		// 1. get contents of url in a string
											
						// 2. match title
preg_match('/<title>(.*)<\/title>/i', $contents, $title);

print $title[1];				// 3. print result

?>

Basic scraping demo with “foreach” and “regex” parsing

<?php

/*	Basic scraping demo with "foreach" and "regex" parsing
 *	Owen Mundy Copyright 2011 GNU/GPL */

// url to start
$url = "http://www.bbc.co.uk/news/";

// get contents of url in an array
$lines = file($url);

// look for the string
foreach ($lines as $line_num => $line) 
{	
	// find opening string
	if(strpos($line, '<h2 class="top-story-header ">')) 
	{
		$get_content = true;
	}
	
	// if opening string is found 
	// then print content until closing string appears
	if($get_content == true) 
	{
		$data .= $line . "\n";
	}

	// closing string
	if(strpos($line, "</h2>")) 
	{
		$get_content = false;
	}
}

// use regular expressions to extract only what we need...

// png, jpg, or gif inside a src="..." or src='...' 
$pattern = "/src=[\"']?([^\"']?.*(png|jpg|gif))[\"']?/i";
preg_match_all($pattern, $data, $images);

// text from link
$pattern = "/(<a.*>)(\w.*)(<.*>)/ismU";
preg_match_all($pattern, $data, $text);

// link
$pattern = "/(href=[\"'])(.*?)([\"'])/i";
preg_match_all($pattern, $data, $link);

/* 
// test if you like
print "<pre>";
print_r($images);
print_r($text);
print_r($link);
print "</pre>";
*/

?>

<html>
<head>
<style> 
body { margin:0; } 
.textblock { position:absolute; top:600px; left:0px; }
span { font:5.0em/1.0em Arial, Helvetica, sans-serif; line-height:normal; 
background:url(trans.png); color:#fff; font-weight:bold; padding:5px } 
a { text-decoration:none; color:#900 }
</style>
</head>
<body>
<img src="<?php print $images[1][0] ?>" height="100%"> </div>
<div class="textblock"><span><a href="<?php print "http://www.bbc.co.uk".$link[2][0] ?>"><?php print $text[2][0] ?></a></span><br>
</div>
</body>
</html>

And the example, which presents the same information in a new way…

Advanced scraping demo with “regex” parsing. Retrieves current weather in any city and colors the background accordingly. The math below for normalization could use some work.

<?php

/*	Advanced scraping demo with "regex" parsing. Retrieves current 
 * 	weather in any city and colors the background accordingly. 
 *	The math below for normalization could use some work.
 *	Owen Mundy Copyright 2011 GNU/GPL */

?>

<html>
<head>
<style> 
body { margin:20; font:1.0em/1.4em Arial, Helvetica, sans-serif; } 
.text { font:10.0em/1.0em Arial, Helvetica, sans-serif; color:#000; font-weight:bold; } 
.navlist { list-style:none; margin:0; position:absolute; top:20px; left:200px }
.navlist li { float:left; margin-right:10px; }
</style>
</head>

<body onLoad="document.f.q.focus();">

<form method="GET" action="<?php print $_SERVER['PHP_SELF']; ?>" name="f">

	<input type="text" name="q" value="<?php print $_GET['q'] ?>" />
	<input type="submit" />

</form>

<ul class="navlist">
	<li><a href="?q=anchorage+alaska">anchorage</a></li>
	<li><a href="?q=toronto+canada">toronto</a></li>
	<li><a href="?q=new+york+ny">nyc</a></li>
	<li><a href="?q=london+uk">london</a></li>
	<li><a href="?q=houston+texas">houston</a></li>
	<li><a href="?q=linz+austria">linz</a></li>
	<li><a href="?q=rome+italy">rome</a></li>
	<li><a href="?q=cairo+egypt">cairo</a></li>
	<li><a href="?q=new+delhi+india">new delhi</a></li>
	<li><a href="?q=mars">mars</a></li>
</ul>

<?php

// make sure the form has been sent
if (isset($_GET['q']))
{
	// get contents of url in an array
	if ($str = file_get_contents('http://www.google.com/search?q=weather+in+'
						. str_replace(" ","+",$_GET['q'])))
	{
		
		// use regular expressions to extract only what we need...
		
		// 1, 2, or 3 digits followed by any version of the degree symbol 
		$pattern = "/[0-9]{1,3}[º°]C/";
		// match the pattern with a C or with an F
		if (preg_match_all($pattern, $str, $data) > 0)
		{
			$scale = "C";
		}
		else
		{
			$pattern = "/[0-9]{1,3}[º°]F/";
			if (preg_match_all($pattern, $str, $data) > 0)
			{
				$scale = "F";
			}
		}
		
		// remove html
		$temp_str = strip_tags($data[0][0]);
		// remove everything except numbers and points
		$temp = ereg_replace("[^0-9..]", "", $temp_str);
		
		if ($temp)
		{
			
			// what is the scale?
			if ($scale == "C"){
				// convert ºC to ºF
				$tempc = $temp;
				$tempf = ($temp*1.8)+32;
			}
			else if ($scale == "F")
			{
				// convert ºF to ºC
				$tempc = ($temp-32)/1.8;
				$tempf = $temp;
			}
			// normalize the number
			$color = round($tempf/140,1)*10;
			// cool -> warm
			// scale -20 to: 120
			$color_scale = array(
					'0,  0,255',
					'0,128,255',
					'0,255,255',
					'0,255,128',
					'0,255,0',
					'128,255,0',
					'255,255,0',
					'255,128,0',
					'255,  0,0'
					);	
		
?>

<style> body { background:rgb(<?php print $color_scale[$color] ?>) }</style>
<div class="text"><?php print round($tempc,1) ."&deg;C " ?></div>
<?php print round($tempf,1) ?>&deg;F

<?php
		
		}
		else 
		{
			print "city not found";	
		}
	}
}
?>

</body>
</html>




For an xpath tutorial check this page.

For the next part of the workshop we used Give Me My Data to export our information from Facebook in order to revisualize it with Nodebox 1.0, a Python IDE similar to Processing.org. Here’s an example:

Update: Some user images from the workshop. Thanks all who joined!

Mutual friends (using Give Me My Data and Graphviz) by Rob Canning

identi.ca network output (starting from my username (claude) with depth 5, rendered to svg with ‘sfdp’ from graphviz) by Claude Heiland-Allen

Freedom for Our Files: Creative Reuse of Personal Data Workshop at Art Meets Radical Openness in Linz, Austria

This weekend I am presenting a lecture about GIve Me My Data and conducting a two-day data-scraping workshop at Art Meets Radical Openness in Linz, Austria. Here are the details.

The Self-Indulgence of Closed Systems
May 13, 18:45 – 19:15
Part artist lecture, part historical context, Owen Mundy will discuss his Give Me My Data project within the contexts of the history of state surveillance apparatuses, digital media and dialogical art practices, and the ongoing contradiction of privacy and utility in new media.

Freedom for Our Files: Creative Reuse of Personal Data
May 13-14, 14:00 – 16:30
A two-day workshop, with both technical hands-on and idea-driven components. Learn to scrape data and reuse public and private information by writing custom code and using the Facebook API. Additionally, we’ll converse and conceptualize ideas to reclaim our data literally and also imagine what is possible with our data once it is ours! Register here


Art Meets Radical Openness (LiWoLi 2011),
Date: 12th – 14th May 2011
Location: Kunstuniversität Linz, Hauptplatz 8, 4020 Linz, Austria

Observing, comparing, reflecting, imitating, testing, combining

LiWoLi is an open lab and meeting spot for artists, developers and educators using and creating FLOSS (free/libre open source software) and Open Hardware in the artistic and cultural context. LiWoLi is all about sharing skills, code and knowledge within the public domain and discussing the challenges of open practice.

A Single Composite, May 7–June 24, Bauer&Ewald, Berlin

This week I am installing an ambitious new project in a quaint and friendly space called bauer&ewald located in Kreuzberg / Neuköln (Berlin) opening on May 7 until the end of June. There will be a party on the evening of the opening day. Please come if you are in town.

You can see a video of a small study online here and here.

A Single Composite
Owen Mundy

May 7–June 24

Vernissage (opening): May 7, 19:00+
Finissage (closing): June 23, 19:00+

“Nothing now distinguishes the function of the weapon and the eye; the projectile’s image and the image’s projectile form a single composite.”
—Paul Virilio in “War & Cinema”

A Single Composite is a kinetic installation and multi-projection/viewing apparatus consisting of one 100cm wide film strip stretched, twisted, and looped through multiple spaces by reconstituted digital printer chassis. This cinematic enterprise, a sprawling film through which declassified and other found reconnaissance footage is projected on walls, ceilings, and floors, forms a series of individual moments of surveillance and implied violence.

Bauer&Ewald
Lenaustraße 20
12047 Neukölln-Berlin
u8 schönleinstraße, u7/u8 hermannplatz

http://bauerundewald.com

Öffnungszeiten (open hours):
Mo-Sa ab 18:00, So ab 16:00
jeweils bis spätnachts (until late)

Give Me My Data on Today Show’s Digital Life blog

How to back up your Facebook data
By Rosa Golijan

“There are plenty of reasons to back up your Facebook data — maybe you want to archive, reuse, or save it — and it turns out that there’s a simple way to do so. In fact, a few clicks and an app called Give Me My Data will do the trick in seconds.

Give Me My Data is a simple Facebook app with a single purpose — to help you back up your Facebook data so that you can do whatever you wish with it — and it does it well.

All you need to do is add the application, authorize it to access your information, and select how you want to receive your data — options include plain text, CSV, and XML formats — and … that’s it. Give Me My Data will proceed to spit out your details by category — personal information, status updates, links, pages, etc — and then you’re free to do whatever you will with it.

It’s worth noting that Facebook itself provides a way to download most of your data — the link to do so can be found in your account settings — but it doesn’t provide the various formatting options nor the varying breakdowns of data.”

Continue reading

Art Meets Radical Openness (LiWoLi 2011), May 12-14, Linz, Austria

Art Meets Radical Openness (LiWoLi 2011)

Date: 12th – 14th May 2011
Location: Kunstuniversität Linz, Hauptplatz 8, 4020 Linz

Observing, comparing, reflecting, imitating, testing, combining

LiWoLi is an open lab and meeting spot for artists, developers and educators using and creating FLOSS (free/libre open source software) and Open Hardware in the artistic and cultural context. LiWoLi is all about sharing skills, code and knowledge within the public domain and discussing the challenges of open practice.

This year’s event offers an exhibition, artists’ workshops and – like every year – lectures, presentations and sound-performances.

with:
minipimer.tv (ES), Aileen Derieg (A), Martin Howse (UK/DE), Jorge Crowe (AR)pending), Malte Steiner(DE), Servando Barreiro (ES), Enrique Tomás(ES/A), Peter Bubestinger (A), Stefan Hageneder (A), Audrey Samson (CA/NL), Sabrina Baston (DE), Sebastian Pichelhofer (A), Barbara Huber (A), Max Nagele (A), Helen Varley Jamieson (NZ/DE), Adnan Hadzi (GB), André Carvalho Hostalácio (BR/DE), Claudia González Godoy (CL), Dominik Leitner (A), Rob Canning (IR/UK), Marloes de Valk (NL), Owen Mundy (US/DE), Dušan Barok (Sk), Nicolas Malevé (BE), Margaritha Köhl (A), Pippa Buchanan (AU/A), Birgit Bachler (A/NL),…

More information: http://liwoli.at/

Through A Glass Darkly: Epilogue

I am premiering this “Epilogue” for Through A Glass Darkly today in New York at Flux Factory.

Here is an excerpt from the script:

“In my short film, Through A Glass Darkly, I steer the focus away from the narrative, away from the explosions and violence, away from the masculine overload, and towards the serene landscapes where hollywood produces its fictional wars.

Through A Glass Darkly is a remix of landscapes from popular films that depict conflict. The chronological compilation relies on the influence of cinema to access a collective memory of images of war. While peaceful, they are frightening moments in their original context, used to contrast tranquility with chaos, beauty with destruction, and property with the actions that attempt its acquisition. Seen in this form, they remind the viewer that war is violent and chaotic while questioning the idea that conflict is a means to an harmonious end.”

Geographical and Social Landscapes of Conflict, Both Real and Perceived @ Flux Factory, Thursday April 14

If you are in New York this week go see this screening and exhibition curated by Elizabeth Larison at Flux Factory (in Long Island City near PS1). In addition to screening Through A Glass Darkly I will also be premiering a special Epilogue to accompany the film.

Geographical and Social Landscapes of Conflict, Both Real and Perceived:
A Special Flux Thursday

Thursday, April 14
8 pm +

Join us for Flux Thursday, our monthly potluck and salon. Dinner starts at 8, with presentations to follow. As part of The Typhoon Continues and So Do You, we are happy to present Geographical and Social Landscapes of Conflict, Both Real and Perceived, a pair of videos curated by Elizabeth Larison. Through a Glass Darkly, a short film by Owen Mundy, brings together over one hundred of the most popular war films edited into a chronologically correct survey of landscapes of conflict, at least according to Hollywood. Untitled part 2: beauty and the east, a documentary by Jayce Salloum, addresses issues of nationalism and the nation state, alienation, ethno-facism, polarities of time – among others – as described in a series of interviews with individuals from former Yugoslavia.

Owen Mundy, Through a Glass Darkly, 2011

-->