[Release] Parsedom and other functions
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:
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
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:
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
Reply


Messages In This Thread
[No subject] - by Popeye - 2011-12-09, 12:01
[No subject] - by TobiasTheCommie - 2011-12-09, 17:42
[No subject] - by Popeye - 2011-12-09, 23:16
[No subject] - by TobiasTheCommie - 2011-12-10, 06:43
[No subject] - by _Pierre_ - 2011-12-10, 12:43
[No subject] - by bossanova808 - 2011-12-11, 06:42
[No subject] - by TobiasTheCommie - 2011-12-11, 13:09
[No subject] - by bossanova808 - 2011-12-11, 14:16
[No subject] - by TobiasTheCommie - 2011-12-11, 14:27
[No subject] - by bossanova808 - 2011-12-11, 14:35
[No subject] - by TobiasTheCommie - 2011-12-12, 01:58
[No subject] - by bossanova808 - 2011-12-12, 08:20
[No subject] - by _Pierre_ - 2011-12-12, 11:40
[No subject] - by TobiasTheCommie - 2011-12-12, 12:13
[No subject] - by TobiasTheCommie - 2011-12-12, 14:03
[No subject] - by _Pierre_ - 2011-12-12, 14:13
[No subject] - by TobiasTheCommie - 2011-12-12, 14:34
[No subject] - by _Pierre_ - 2011-12-12, 15:47
[No subject] - by TobiasTheCommie - 2011-12-12, 16:12
[No subject] - by _Pierre_ - 2011-12-12, 18:13
[No subject] - by TobiasTheCommie - 2011-12-12, 18:55
[No subject] - by _Pierre_ - 2011-12-12, 19:11
[No subject] - by TobiasTheCommie - 2011-12-12, 19:24
[No subject] - by bossanova808 - 2011-12-13, 01:20
[No subject] - by TobiasTheCommie - 2011-12-13, 02:00
[No subject] - by bossanova808 - 2011-12-13, 02:06
[No subject] - by TobiasTheCommie - 2011-12-13, 02:28
[No subject] - by bossanova808 - 2011-12-13, 04:10
[No subject] - by newatv2user - 2011-12-13, 06:53
[No subject] - by TobiasTheCommie - 2011-12-13, 15:55
[No subject] - by newatv2user - 2011-12-13, 17:24
[No subject] - by _Pierre_ - 2011-12-13, 20:18
[No subject] - by TobiasTheCommie - 2011-12-13, 23:08
[No subject] - by _Pierre_ - 2011-12-14, 21:25
[No subject] - by TobiasTheCommie - 2011-12-14, 22:13
[No subject] - by _Pierre_ - 2011-12-14, 22:27
[No subject] - by _Pierre_ - 2011-12-15, 20:11
[No subject] - by Martijn - 2011-12-15, 20:17
[No subject] - by _Pierre_ - 2011-12-15, 20:27
[No subject] - by Martijn - 2011-12-15, 20:32
[No subject] - by _Pierre_ - 2011-12-15, 20:35
[No subject] - by TobiasTheCommie - 2011-12-16, 00:33
[No subject] - by TobiasTheCommie - 2011-12-16, 00:37
[No subject] - by bossanova808 - 2011-12-16, 00:54
[No subject] - by bossanova808 - 2011-12-16, 00:55
[No subject] - by TobiasTheCommie - 2011-12-16, 01:40
[No subject] - by newatv2user - 2011-12-16, 02:17
[No subject] - by TobiasTheCommie - 2011-12-16, 02:29
[No subject] - by takoi - 2011-12-20, 23:54
[No subject] - by TobiasTheCommie - 2011-12-21, 00:25
[No subject] - by takoi - 2011-12-21, 13:35
[No subject] - by stacked - 2011-12-22, 04:05
[No subject] - by TobiasTheCommie - 2011-12-22, 04:07
[No subject] - by takoi - 2011-12-25, 22:34
[No subject] - by TobiasTheCommie - 2011-12-25, 23:48
[No subject] - by takoi - 2011-12-26, 01:54
[No subject] - by TobiasTheCommie - 2011-12-26, 03:57
[No subject] - by takoi - 2012-01-03, 15:06
[No subject] - by TobiasTheCommie - 2012-01-03, 15:46
[No subject] - by takoi - 2012-01-05, 17:47
[No subject] - by TobiasTheCommie - 2012-01-05, 17:59
[No subject] - by takoi - 2012-01-08, 15:19
[No subject] - by TobiasTheCommie - 2012-01-08, 15:30
[No subject] - by BlueCop - 2012-01-09, 23:02
[No subject] - by TobiasTheCommie - 2012-01-27, 01:42
[No subject] - by bossanova808 - 2012-01-27, 07:51
[No subject] - by TobiasTheCommie - 2012-01-27, 13:16
[No subject] - by newatv2user - 2012-01-30, 04:34
[No subject] - by TobiasTheCommie - 2012-01-30, 15:49
[No subject] - by newatv2user - 2012-01-31, 02:18
[No subject] - by TobiasTheCommie - 2012-01-31, 02:24
[No subject] - by newatv2user - 2012-01-31, 02:36
[No subject] - by newatv2user - 2012-01-31, 05:22
[No subject] - by newatv2user - 2012-02-04, 06:14
[No subject] - by TobiasTheCommie - 2012-02-04, 12:08
[No subject] - by newatv2user - 2012-02-04, 16:42
[No subject] - by TobiasTheCommie - 2012-02-04, 17:37
[No subject] - by newatv2user - 2012-02-05, 08:34
[No subject] - by TobiasTheCommie - 2012-02-05, 12:11
[No subject] - by newatv2user - 2012-02-05, 16:51
RE: [Release] Parsedom and other functions - by Kr0nZ - 2013-01-01, 23:53
Logout Mark Read Team Forum Stats Members Help
[Release] Parsedom and other functions1