summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrent s <r00t@square-r00t.net>2020-07-14 17:30:47 -0400
committerbrent s <r00t@square-r00t.net>2020-07-14 17:30:47 -0400
commit743edf045bb2e91cdfa7b62f31485e0e8f0f2dc8 (patch)
treefb77bbadc1c090e4414db61e05c824726d37f2a4
parent8f3da5ee34b84fd47f48ef384bb82278af8cf540 (diff)
downloadOpTools-743edf045bb2e91cdfa7b62f31485e0e8f0f2dc8.tar.xz
adding count
-rwxr-xr-xnet/get_title.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/net/get_title.py b/net/get_title.py
index 495c2c5..ce2c1e0 100755
--- a/net/get_title.py
+++ b/net/get_title.py
@@ -49,17 +49,21 @@ class InfoScraper(object):
def parseArgs():
args = argparse.ArgumentParser(description = 'Get quick information from a URL at a glance')
args.add_argument('-e', '--elem',
- dest = 'strip',
+ dest = 'elem',
default = def_elem,
help = ('The element(s) you want to scrape from the page. This is likely just going to be "{0}" (the default)').format(def_elem))
args.add_argument('-s', '--strip',
dest = 'strip',
action = 'store_true',
- help = ('Whether to strip whitespace at the beginning/end of each element text'))
+ help = ('If specified, strip whitespace at the beginning/end of each element text'))
args.add_argument('-d', '--delineate',
dest = 'delin',
action = 'store_true',
- help = ('Whether to delineate each element instance'))
+ help = ('If specified, delineate each element instance'))
+ args.add_argument('-c', '--count',
+ dest = 'count',
+ action = 'store_true',
+ help = ('If specified, provide a count of how many times -e/--elem was found'))
args.add_argument('url',
metavar = 'URL',
help = ('The URL to parse. It may need to be quoted or escaped depending on the URL and what shell you\'re using'))
@@ -70,6 +74,8 @@ def main():
args = parseArgs().parse_args()
i = InfoScraper(**vars(args))
rslts = i.find()
+ if args.count:
+ print('Element {0} was found {1} time(s) at {2}. Results follow:'.format(args.elem, len(rslts), args.url))
for i in rslts:
t = i.text
if args.strip: