about summary refs log tree commit diff
path: root/lsb.py
diff options
context:
space:
mode:
authorZach DeCook <zachdecook@librem.one>2023-01-26 17:29:51 -0500
committerZach DeCook <zachdecook@librem.one>2023-01-26 17:29:51 -0500
commit3dd57e2099d34ddd6b87fdec6312598cd1a234e0 (patch)
tree7873472948bff15f492ed03350b9c2344fcc74db /lsb.py
parent0670aba0246cc75f704e12cc925b170d37b116e1 (diff)
downloadcgi-bin-3dd57e2099d34ddd6b87fdec6312598cd1a234e0.tar.gz
lsb: Add Legacy Standard Bible script
(parses their HTML, which is okay, and loads fast)
Diffstat (limited to 'lsb.py')
-rwxr-xr-xlsb.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/lsb.py b/lsb.py
new file mode 100755
index 0000000..1793ba5
--- /dev/null
+++ b/lsb.py
@@ -0,0 +1,20 @@
+#!/usr/bin/env python3
+from bs4 import BeautifulSoup
+import sys
+import os
+import requests
+
+def main(qs):
+  url="https://read.lsbible.org/?q="+qs
+  r = requests.get(url)
+  soup = BeautifulSoup(r.text)
+  passage = soup.find_all("div",attrs={"class":"passage"})[0]
+  # remove verse numbers
+  for versenumber in passage.find_all("small"):
+    versenumber.decompose()
+  # Print text portions, separated by a space.
+  print(passage.get_text(" "))
+
+if __name__ == '__main__':
+  qs = os.getenv("QUERY_STRING") or (sys.argv[1] if len(sys.argv) >= 2 else '')
+  main(qs)