This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// La posizione del punto viene dichiarata con due variabili x ed y | |
int x = 100; | |
int y = 100; | |
void setup(){ | |
size(640, 360); | |
} | |
void draw(){ | |
background(0); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void setup(){ | |
size(640, 360); | |
} | |
void draw(){ | |
background(0); | |
point(100, 100); // La posizione del punto viene dichiarata all'interno della funzione point | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$data = "http://feeds.feedburner.com/metroq?format=xml"; | |
$ch = curl_init($data); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); | |
curl_setopt($ch, CURLOPT_POST, false); | |
$result = curl_exec($ch); | |
curl_close($ch); | |
$xmlRawDoc = $result; | |
$xmlDoc = new DOMDocument(); | |
$xmlDoc->loadXML($xmlRawDoc); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ERROR:root:Uncaught exception, closing connection. | |
Traceback (most recent call last): | |
File "/usr/local/lib/python2.6/dist-packages/tornado-2.1.1-py2.6.egg/tornado/iostream.py", line 301, in wrapper | |
callback(*args) | |
File "/usr/local/lib/python2.6/dist-packages/tornado-2.1.1-py2.6.egg/tornado/httpserver.py", line 248, in _on_headers | |
self.request_callback(self._request) | |
File "nauauProxy.faster.async.py", line 22, in handle_request | |
self.client.fetcher(req) | |
AttributeError: httpProxy instance has no attribute 'client' | |
ERROR:root:Exception in callback <tornado.stack_context._StackContextWrapper object at 0x1a6fd60> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Async Version with AsyncHTTPClient as url fetcher | |
from tornado import httpserver, ioloop | |
from tornado.httpclient import AsyncHTTPClient, HTTPClient | |
class httpProxy(): | |
def __init__(self, iolp): | |
self.myserv = httpserver.HTTPServer(self.handle_request) | |
self.myserv.listen(8080) | |
self.httpclient = AsyncHTTPClient() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
text = TokenizedText | |
def textStats(text): | |
length = 0 | |
punctuation = 0 | |
smallWordsCount = 0 | |
for word in text: | |
if(word == "," or word == "." or word == ";" or word == ":"): | |
punctuation += 1 | |
else: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import robotparser | |
toget = "http://johannburkard.de/blog/www/spam/The-top-10-spam-bot-user-agents-you-MUST-block-NOW.html" | |
roboturl = "http://johannburkard.de/robots.txt" | |
userAgent = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/534.30 (KHTML, like Gecko) Ubuntu/10.04 Chromium/12.0.742.112 Chrome/12.0.742.112 Safari/534.30" | |
pars = robotparser.RobotFileParser() | |
pars.set_url(roboturl) | |
pars.read() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import lxml.etree as jq | |
string = "<p><b>HTTP header fields</b> are components of the message header of requests and responses in the <a href=\"/wiki/Hypertext_Transfer_Protocol\" title=\"Hypertext Transfer Protocol\">Hypertext Transfer Protocol</a> (HTTP). They define the operating parameters of an HTTP transaction.</p>" | |
html = jq.fromstring(string) | |
for par in html.xpath("//p"): | |
print par.text_content() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Traceback (most recent call last): | |
File "/usr/lib/python2.6/multiprocessing/process.py", line 232, in _bootstrap | |
self.run() | |
File "/usr/lib/python2.6/multiprocessing/process.py", line 88, in run | |
self._target(*self._args, **self._kwargs) | |
File "xmlFasterParser.py", line 19, in mainParser | |
for event, elem in context: | |
File "iterparse.pxi", line 515, in lxml.etree.iterparse.__next__ (src/lxml/lxml.etree.c:86643) | |
File "parser.pxi", line 565, in lxml.etree._raiseParseError (src/lxml/lxml.etree.c:64088) | |
XMLSyntaxError: xmlParseCharRef: invalid xmlChar value 11, line 28153825, column 161 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def dataExtractor(node): | |
XMLNS_D = '{http://purl.org/dc/elements/1.0/}' | |
elem = tr.fromstring(node) | |
title = elem.find(XMLNS_D + 'Title').text | |
if title is not None: | |
title = title | |
else: | |
title = "nnn" | |
descr = elem.find(XMLNS_D + 'Description').text | |
if descr is not None: |