Originally Posted by
gatoki
Thanks for the script, methrend! The lag is causing me a lot of grief, but I made a few tweaks to the "NeoAccount.py" calls to "get" and "post" that have stopped the crashing on my end. Here's the code in case you're interested:
def get(self, url, referer = '', readable = True):
if url[0] == '/':
url = self.d + url
if referer == '':
referer = self.referer
self.opener.addheaders = [('Referer', referer)] + self.headers
while True:
try:
res = self.opener.open(url, None)
self.referer = res.geturl()
if readable:
theret = self.readable(res)
self.cleanhtml = theret.replace('"',"'")
return theret
else:
theret = str(res)
self.cleanhtml = theret.replace('"',"'")
return res
except:
time.sleep(5)
def post(self, url, data, referer = '', readable = True):
if url[0] == '/':
url = self.d + url
if referer == '':
referer = self.referer
self.opener.addheaders = [('Content-Type', 'application/x-www-form-urlencoded'),
('Referer', referer)] + self.headers
while True:
try:
res = self.opener.open(url, urllib.urlencode(data))
self.referer = res.geturl()
if readable:
theret = self.readable(res)
self.cleanhtml = theret.replace('"',"'")
return theret
else:
theret = str(res)
self.cleanhtml = theret.replace('"',"'")
return res
except:
time.sleep(5)
Since they're encapsulated, they can safely time out without forcing the user to restart the program, and I added a loop with a five second delay to try again. I haven't had any performance hiccups since.
Thanks again! I can't wait to get the trophy for this!