File: unpack-firefox-user-agent-switcher

package info (click to toggle)
golang-github-corpix-uarand 0.1.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 320 kB
  • sloc: python: 55; makefile: 27; sh: 7
file content (21 lines) | stat: -rwxr-xr-x 561 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/bin/env python3
import sys
import xml.etree.ElementTree as XML
from argparse import ArgumentParser


if __name__ == "__main__":
    p = ArgumentParser(
        description=(
            "Expects XML from "
            "http://techpatterns.com/downloads/firefox/useragentswitcher.xml "
            "to be passed into STDIN and outputs user agents from this XML."
        )
    )
    p.parse_args()

    doc = XML.iterparse(sys.stdin)
    for _, node in doc:
        ua = node.get("useragent")
        if ua != "" and ua is not None:
            print(ua)