I have a scenario where I am searching through values in a beautiful soup result set and treating them differently depending on their contents, eg:
for i in bs_result_set:
if 'this unique string' in i.text:
print 'aaaa'
else:
print 'bbbb'
However I have realised that the unique condition actually occurs twice in the result set however I do not need that second replicate value and therefore want to remove it from the result set in the first place.
I have tried approaches to removing duplicate values in a list
(whilst preserving order) but these do not seem to work on an object that is a beautiful soup result set. Eg i used logic from this post to try:
from collections import OrderedDict
OrderedDict.fromkeys(bs_result_set).keys()
But that didn't seem to remove the duplicate values.
So my question is how do i remove duplicate values from a beautiful soup result set whilst preserving order?