User:Lidia.Pereira/SDRII/SG: Difference between revisions
No edit summary |
No edit summary |
||
Line 44: | Line 44: | ||
places.commit() | places.commit() | ||
#open url's, use beautiful soup to extract the titles of the pages, update statuses | |||
for item in lista: | for item in lista: | ||
try: | try: |
Revision as of 18:18, 27 January 2014
Following my essay I was quite interested in the idea of how implicit participation makes use of design choices to benefit from user generated content, thus contributing to information management systems which can be exploited for improving information retrieval/market research. In order for this process to be optimized, production of social relations becomes the new paradigm under post-industrialist market rule, for it is communication which produces economic value. Immaterial labor, then, both satisfies and produces a demand, ultimately forming subjectivity. Inspired by this idea, I'm experimenting with posting my browsing history on social media, which will ultimately start suggesting me people I might "like" to follow, pages I "might" like, subsequentely leading me to browse new links and so on and so forth. The idea is that, at some point, I'll stop having agency, playing the idea of a hetero-generative subjectivity to the extreme.
Mix Script (posts both on Facebook and Twitter):
import sqlite3, re, time
import urllib2
from bs4 import BeautifulSoup
import tweepy, facepy
from facepy import GraphAPI
consumer_key="aJiJkOEdd3YKiXVRyfnWDg"
consumer_secret="8TDG4KqBLZPqcvjNFZb7qtJ7brSyqnuTNd1Y9yQrEM"
access_token="2308513993-50VDXIyyKvmITBrGEyvzzVa00v6y3KZoihtf5xs"
access_token_secret="53g8fdSl2URB4SY294XncUgAjGcmojWfRjacc3Hjuk2XD"
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)
graph=GraphAPI("CAATZCEv2dRlABABZBEjBMq3SudDcSoP5MzZBrccwM7eDhnelmgELB3LBHJ17Fez31GC0YZCYFJparvjUXXZCD\
Qb1pLFZCmSWA9yZCDOQY5MfUvvv9Xc2YgQ9OvEGazwutXYZAad1Po4tIdnuAOSR0ZBHVX3VIgOV1WBHAuxZB7Wi87Y11GEcuDKwiXVZCUbuQPOIHMZD")
places = sqlite3.connect("places.sqlite")
database = places.cursor()
database.execute('''SELECT url FROM moz_places''')
january = re.compile(r"http://\S+\w")
lista = []
#get the urls in the database, erase them once they're extracted
for data in database:
urls = database.fetchall()
for url in urls:
february = str(url)
march = january.findall(february)
april = str(march)
may = april.strip("['']")
if may != "":
lista.append(may)
database.execute('''DELETE FROM moz_places WHERE url=?''',(url))
places.commit()
#open url's, use beautiful soup to extract the titles of the pages, update statuses
for item in lista:
try:
june = urllib2.urlopen(item)
july = june.read()
august = BeautifulSoup(july)
if august.title != None:
september = august.title.string
if september != None:
october = september.encode("utf-8")
if october not in status:
try:
api.update_status(october)
graph.post(path="me/feed", message = october)
except tweepy.error.TweepError or facepy.exceptions.FacebookError or httplib.BadStatusLine:
print "Caca!"
time.sleep(3)
except urllib2.HTTPError:
print "Bah!"
First successful attempt with Twitter:
import sqlite3, re, time
import urllib2
import bs4
import tweepy
consumer_key="aJiJkOEdd3YKiXVRyfnWDg"
consumer_secret="8TDG4KqBLZPqcvjNFZb7qtJ7brSyqnuTNd1Y9yQrEM"
access_token="2308513993-50VDXIyyKvmITBrGEyvzzVa00v6y3KZoihtf5xs"
access_token_secret="53g8fdSl2URB4SY294XncUgAjGcmojWfRjacc3Hjuk2XD"
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)
places = sqlite3.connect("places.sqlite")
database = places.cursor()
database.execute('''SELECT url FROM moz_places''')
january = re.compile(r"http://\S+\w")
lista = []
#get the urls
for data in database:
url = database.fetchone()
february = str(url)
march = january.findall(february)
april = str(march)
may = april.strip("['']")
if may != "":
lista.append(may)
status = open("status.txt").read()
octo = ""
for item in lista:
try:
june = urllib2.urlopen(item)
july = june.read()
august = BeautifulSoup(july)
if august.title != None:
september = august.title.string
if september != None:
october = september.encode("utf-8")
octo = octo + " " + october
if october not in status:
try:
api.update_status(october)
except tweepy.error.TweepError:
print "Repetido!"
time.sleep(2)
except urllib2.HTTPError:
print "Bah!"
if item == lista[len(lista)-1]:
f = open("status.txt","a")
f.write(octo)
First successful attempt with Facebook:
import sqlite3, re, time
import urllib2
from bs4 import BeautifulSoup
import bs4
from facepy import GraphAPI
import facepy
graph=GraphAPI("CAATZCEv2dRlABABZBEjBMq3SudDcSoP5MzZBrccwM7eDhnelmgELB3LBHJ17Fez31GC0YZCYFJparvjUXXZCDQb1\
pLFZCmSWA9yZCDOQY5MfUvvv9Xc2YgQ9OvEGazwutXYZAad1Po4tIdnuAOSR0ZBHVX3VIgOV1WBHAuxZB7Wi87Y11GEcuDKwiXVZCUbuQPOIHMZD")
places = sqlite3.connect("places.sqlite")
database = places.cursor()
database.execute('''SELECT url FROM moz_places''')
january = re.compile(r"http://\S+\w")
lista = []
#get the urls
for data in database:
url = database.fetchone()
february = str(url)
march = january.findall(february)
april = str(march)
may = april.strip("['']")
if may != "":
lista.append(may)
status = open("facestatus.txt").read()
octo = ""
for item in lista:
try:
june = urllib2.urlopen(item)
july = june.read()
august = BeautifulSoup(july)
if august.title != None:
september = august.title.string
if september != None:
october = september.encode("utf-8")
octo = octo + " " + october
if october not in status:
try:
graph.post(path="me/feed", message = october)
except facepy.exceptions.FacebookError:
print "SAY WHA?"
print facepy.exceptions.FacebookError
time.sleep(3)
except urllib2.HTTPError or httplib.BadStatusLine:
print "Bah!"
if item == lista[len(lista)-1]:
f = open("facestatus.txt","a")
f.write(octo)