← Back to team overview

sikuli-driver team mailing list archive

[Question #259267]: socket error ([Erno 32] Socket closed)

 

New question #259267 on Sikuli:
https://answers.launchpad.net/sikuli/+question/259267

Hi!

I am a brand new user of sikuli (and almost a noob at coding) and I'm using it for an Interaction Design project.

Recently I had an error while trying to connect to the internet to parse some html via the Sikuli IDE (I'm using the last version of Sikulix).

When I run my sript I get this error:

[error] script [ fiznik ] stopped with error in line 29
[error] socket.error ( [Errno 32] Socket closed )
[error] --- Traceback --- error source first
line: module ( function ) statement 
174: socket ( handle_exception ) socket.error: [Errno 32] Socket closed
585: httplib ( _read_chunked ) File "/Users/PXP/Documents/SIKULI/sikulix.jar/Lib/socket.py", line 1733, in readline
1651: socket ( read ) File "/Users/PXP/Documents/SIKULI/sikulix.jar/Lib/httplib.py", line 543, in read
[error] --- Traceback --- end --------------

and this is the code

from HTMLParser import HTMLParser
import urllib2

ignoredLinks = ["[","]"," N "]
linklist = []

class MyHTMLParser(HTMLParser):
	def __init__(self):
		HTMLParser.__init__(self)
		self.currentLink = None
		self.inParagraph = False
	
	def handle_starttag(self, tag, attrs):
		if(tag=='p'): self.inParagraph = True
		elif(self.inParagraph==True and tag=="a"):
			self.currentLink = ""

	def handle_endtag(self, tag):
		if(tag=='p'): self.inParagraph = False
		elif(tag=="a" and self.currentLink!=None and len(self.currentLink)>2):
			if not any(match in self.currentLink for match in ignoredLinks):
				linklist.append(self.currentLink)
				self.currentLink = None

	def handle_data(self, data):
		if self.currentLink!=None: self.currentLink+=data

req = urllib2.urlopen("https://fr.wikipedia.org/wiki/Lausanne";)
html = req.read()
html = unicode(html, req.headers['content-type'].split('charset=')[-1])

parser = MyHTMLParser()
parser.feed(html)

i = 0
for link in linklist:
	i+=1
	print i,":",link



When I run it in a .py file using terminal it works perfectly and retrieves all I need but as you see when I run it from sikulix, something seems to interrupt the process...

Does anyone have an answer? It would be awesome, as  my project is the first step for my Bachelor thesis!

PXP 

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.