Skip to content

Instantly share code, notes, and snippets.

@acagastya
Created September 10, 2018 19:16
Show Gist options
  • Save acagastya/99fe3a282fb13141d408aef15a30c3ae to your computer and use it in GitHub Desktop.
Save acagastya/99fe3a282fb13141d408aef15a30c3ae to your computer and use it in GitHub Desktop.
#!/usr/bin/python3
from bs4 import BeautifulSoup as bsp
import requests
import sys
url = 'https://www.biblegateway.com/passage/?version=KJV&search=' + str(sys.argv[1]) + '%20' + str(sys.argv[2])
page = requests.get(url)
if page.status_code == 404:
print("Verse not found.")
sys.exit(0)
if page.status_code is not 200:
printf(page.status_code)
sys.exit(0)
soup = bsp(page.text, "lxml")
try:
verse = soup.find("span", {"class": "text"})
except TypeError:
print("Verse not found.")
sys.exit(0)
for sup in verse("sup"):
sup.decompose()
for v in verse:
print(v)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment