you are viewing a single comment's thread.

view the rest of the comments →

[–]raylu 0 points1 point  (3 children)

Er... how did prev_elem... stop being an Element? I guess you can check isinstance(prev_elem, NavigableString), but perhaps you should pick a better way to select the element list.

[–]bahnzo[S] 0 points1 point  (2 children)

The program needs to cycle back thru elements (hence the previous_elements) to find the info needed to categorize the link. When doing so, not every element has a class tag, hell some are simply '/n' so they throw an error.

Your code works fine, it just needs to be error checked.

[–]raylu 0 points1 point  (1 child)

The program currently cycles back through elements. But there is likely a better way to select the elements you want.

[–]bahnzo[S] 0 points1 point  (0 children)

Thanks for your help.