Skip to content

Instantly share code, notes, and snippets.

@k0001
Created December 1, 2010 17:50
Show Gist options
  • Save k0001/723895 to your computer and use it in GitHub Desktop.
Save k0001/723895 to your computer and use it in GitHub Desktop.
# NOTE: I have no reason for indenting this like I do.
# But writing scrappers can get boring sometimes, you know.
# -^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^
foo = un(first_or_value(tr.select('//*[preceding-sibling::font/a[contains(., "Bajar")]]')))
# -^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^
if 'nominal' in foo: l.add_value('tipo', 'nominal')
elif 'numerica' in foo: l.add_value('tipo', 'numerica')
else : raise ValueError(u'Not "nominal" nor "numerica" in %s' % foo)
# -^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^
if 'negativa' in foo: l.add_value('resultado', 'negativa')
elif 'afirmatva' in foo: l.add_value('resultado', 'afirmativa')
else : raise ValueError(u'Not "afirmativa" nor "negativa" in %s' % foo)
# -^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^-^v^
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment