| 1 |
#!/usr/bin/env python3 |
| 2 |
import sys |
| 3 |
import xml.etree.ElementTree as XML |
| 4 |
from argparse import ArgumentParser |
| 5 |
|
| 6 |
|
| 7 |
if __name__ == "__main__": |
| 8 |
p = ArgumentParser( |
| 9 |
description=( |
| 10 |
"Expects XML from " |
| 11 |
"http://techpatterns.com/downloads/firefox/useragentswitcher.xml " |
| 12 |
"to be passed into STDIN and outputs user agents from this XML." |
| 13 |
) |
| 14 |
) |
| 15 |
p.parse_args() |
| 16 |
|
| 17 |
doc = XML.iterparse(sys.stdin) |
| 18 |
for _, node in doc: |
| 19 |
ua = node.get("useragent") |
| 20 |
if ua != "" and ua is not None: |
| 21 |
print(ua) |