Fetch a specific chapter from the NIV Bible (via BibleGateway.com) and format it in Joseph's Bible study format.
### {verse number}
> {verse text}
-
Each verse: h3 with number, blockquote with text, hyphen separator, blank line between verses.
browser_navigate → https://www.biblegateway.com/passage/?search={Book}+{Chapter}&version=NIV
Book names should be in full English (e.g., "Philippians", "John", "Genesis").
Use browser_console with this extraction script:
(() => {
const container = document.querySelector('.passage-text');
if (!container) return {error: 'no passage-text container'};
const verses = [];
let currentNum = null;
let currentText = '';
function walk(node) {
if (node.nodeType === 3) {
if (currentNum !== null) {
currentText += node.textContent;
}
} else if (node.nodeName === 'SUP' || node.nodeName === 'SUPERSCRIPT') {
const num = parseInt(node.textContent.trim());
if (num > 0) {
if (currentNum !== null && currentText.trim()) {
verses.push({num: currentNum, text: currentText.trim()});
}
currentNum = num;
currentText = '';
}
} else if (node.nodeName === 'H3' || node.nodeName === 'H4') {
return;
} else {
for (const child of node.childNodes) {
walk(child);
}
}
}
// Handle verse 1: first paragraph often has "4Therefore..." format
const firstP = container.querySelector('p');
if (firstP) {
const text = firstP.textContent.trim();
const match = text.match(/^\d+(.+)/);
if (match) {
verses.push({num: 1, text: match[1].trim()});
}
}
let skipFirst = verses.length > 0;
for (const child of container.children) {
if (skipFirst && child.nodeName === 'P') {
skipFirst = false;
continue;
}
walk(child);
}
if (currentNum !== null && currentText.trim()) {
const exists = verses.find(v => v.num === currentNum);
if (!exists) verses.push({num: currentNum, text: currentText.trim()});
}
return verses;
})()
In Python, clean each verse's text:
(A), (B) → re.sub(r'\s*\([A-Z]\)', '', text)lines = []
for v in verses:
lines.append(f"### {v['num']}")
lines.append(f"> {v['text']}")
lines.append("-")
lines.append("")
output = "\n".join(lines).rstrip("\n")
Return formatted text inside a markdown code block.
(A), (B) markers. Strip in cleanup.Spot-check: verse count, first/last verses clean, no heading text in verse bodies, no footnote content.