2013-01-01, 23:53
hi, I found a bug... Parsedom wasn't returning all elements for me when trying to get <li>'s with other <li>'s as children.
I found the cause and fixed it
At the end of the parsedom function there is this line:
This tries to get the content of every 'match' element in 'lst', but some of the matches could be children of other matches. So its then possible for 'getDOMContent' to return a blank str. The blank string (for me), kept matching the end on the html content, so when the line 'item = item[item.find(temp, item.find(match)) + len(temp):]' executes, it then truncates the entire content.
I fixed it by adding an if clause, so the above now becomes:
I found the cause and fixed it
At the end of the parsedom function there is this line:
Code:
else:
log("Getting element content for %s matches " % len(lst), 3)
lst2 = []
for match in lst:
log("Getting element content for %s" % match, 4)
temp = _getDOMContent(item, name, match, ret).strip()
item = item[item.find(temp, item.find(match)) + len(temp):]
lst2.append(temp)
lst = lst2
I fixed it by adding an if clause, so the above now becomes:
Code:
else:
log("Getting element content for %s matches " % len(lst), 3)
lst2 = []
for match in lst:
log("Getting element content for %s" % match, 4)
temp = _getDOMContent(item, name, match, ret).strip()
if temp:
item = item[item.find(temp, item.find(match)) + len(temp):]
lst2.append(temp)
lst = lst2