File "debug_ibx2.py"

Full path: /home/algopkco/public_html/scraper/debug_ibx2.py
File size: 486 B (486 B bytes)
MIME-type: text/plain
Charset: utf-8

Download   Open   Edit   Advanced Editor &nnbsp; Back

import importlib.util
import re

spec = importlib.util.spec_from_file_location("fibx", r"scraper\fetch_indiabix.py")
mod = importlib.util.module_from_spec(spec)
spec.loader.exec_module(mod)

html = open("https_www_indiabix_comaptitudeprobability.html", encoding="utf-8").read()
blocks = mod.split_blocks(html)
b = blocks[0]
for m in re.finditer(r"<img[^>]*>", b):
    print(m.group(0)[:200])
    s, e = m.span()
    print("  context:", re.sub(r"\s+", " ", b[max(0, s - 150) : e + 150]))