![]() |
|
ValueError - Printable Version +- Sinisterly (https://sinister.li) +-- Forum: Coding (https://sinister.li/Forum-Coding) +--- Forum: Python (https://sinister.li/Forum-Python) +--- Thread: ValueError (/Thread-ValueError) |
ValueError - Equinox - 03-07-2014 I'm working on a top secret project in Python that requires I grab the whois list from SL. I feel retarded for asking, but can anyone help? Code: import urllib,sys
if sys.version_info[0] > 2:
import urllib.request as urlreq
else:
import urllib2 as urlreq
w = urlreq.urlopen('https://www.sinister.ly/')
xread = str(w.read())
if "fuck you bill bergenstein" in xread:
whosonline = "What the fuck?"
else:
(t,c) = xread.split("""<tr><td class="trow1"><span class="smalltext">""",1)
(c,t) = c.split("""</span></td></tr>""",1)
whosonline = c
print(whosonline)RE: ValueError - w00t - 03-07-2014 And what is the error, good sir? RE: ValueError - Equinox - 03-07-2014 (03-07-2014, 07:02 AM)w00t Wrote: And what is the error, good sir? Needs more than 1 value to unpack. RE: ValueError - w00t - 03-07-2014 For whatever reason, split isn't returning a list. It may have something to do with that you restricted it to output only one string. Just a guess though. RE: ValueError - 3SidedSquare - 03-07-2014 The error is happening because there is no place to split, here is the test code, you'll see it can't find your string in the page source Code: import urllib,sys
if sys.version_info[0] > 2:
import urllib.request as urlreq
else:
import urllib2 as urlreq
w = urlreq.urlopen('https://www.sinister.ly/')
xread = str(w.read())
splitvalue = """<tr><td class="trow1"><span class="smalltext">"""
print(splitvalue)
if(splitvalue in xread):
print("I found a place to split!")
else:
print("There is nowhere to split! :(")
if "fuck you bill bergenstein" in xread:
whosonline = "What the fuck?"
else:
allsplits = xread.split(splitvalue)
for part in allsplits:
print("Got a part")
(t,c) = allsplits
(c,t) = c.split("""</span></td></tr>""",1)
whosonline = c
print(whosonline) |