Skip to content

Instantly share code, notes, and snippets.

@merrillcook0

merrillcook0/autoscrape.py Secret

Last active Nov 12, 2020
Embed
What would you like to do?
def _get_valid_attrs(item):
key_attrs = {'class', 'style'}
attrs = {
k: v if v != [] else '' for k, v in item.attrs.items() if k in key_attrs
}
for attr in key_attrs:
if attr not in attrs:
attrs[attr] = ''
return attrs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment