|
|
|
|
|
by simonw
1410 days ago
|
|
For things like regular expressions, it's useful to know that Python has a "-c" option which can be passed a multi-line string as part of a CLI pipeline. You can do something like this: curl 'https://news.ycombinator.com/' | python -c '
import sys, re, json
html = sys.stdin.read()
r = re.compile("<a href=\"(.*)\"")
print(json.dumps(r.findall(html), indent=2))
'
This outputs JSON which you can then pipe to other tools. |
|
[1]: http://novosial.org/perl/one-liner/