# Islamic Fatwa & Religious Research — JS-Routing Pitfall

## The Problem

Major Islamic fatwa sites (IslamQA.info, Islamweb.net) use **client-side JS routing**. The URL path does NOT determine what content is served — the JS framework routes internally. This means:

- `islamqa.info/en/answers/12853/freemasonry` → actually shows a **wedding dress fatwa**
- `islamweb.net/en/fatwa/81342/freemasonry` → actually shows a **hijab fatwa**
- `jina.ai` extraction returns the JS shell or wrong content
- Direct curl/Wikipedia API approaches fail

## The Working Pattern

### Step 1: Discover correct answer IDs via `site:` search + screenshot

```bash
# Open DuckDuckGo with site: operator in Camofox
curl -s -X POST "http://127.0.0.1:9377/tabs" \
  -H "Content-Type: application/json" \
  -d '{"userId":"kiwi","sessionKey":"default","url":"https://duckduckgo.com/?q=site:islamqa.info+freemasonry"}'

# Wait 3-4s for JS render, then screenshot
curl -s "http://127.0.0.1:9377/tabs/$TAB/screenshot?userId=kiwi&sessionKey=default" \
  -o /tmp/ddg_fatwa.png

# Use vision_analyze to read result titles and extract the numeric answer IDs
```

### Step 2: Extract with jina.ai using the CORRECT answer ID

Once you have the real answer ID (e.g. 34576, not 12853):

```bash
curl -sL -A "Mozilla/5.0" "https://r.jina.ai/https://islamqa.info/en/answers/34576/freemasonry-and-ruling-on-joining-the-masons" \
  -H "Accept: text/plain"
```

### Step 3: Fall back to screenshot+vision if jina.ai still fails

Some fatwa sites serve content that jina.ai can't extract even with the correct URL. In that case, open the correct URL directly in Camofox and screenshot+vision it.

## Verified Answer IDs

| Site | Topic | Correct ID | Wrong ID (JS-routed) |
|------|-------|-----------|---------------------|
| IslamQA.info | Freemasonry ruling | **34576** | 12853 (wedding dress) |
| IslamQA.info | Freemasonry (alt) | **549819** | — |
| Islamweb.net | What is Freemasonry | **84203** | 81342 (hijab) |
| Islamweb.net | What is free masonry | **82344** | — |

## Wikipedia API for Historical Figures

For historical Muslim Freemasons, Wikipedia API is the fastest path:

```bash
# Search
curl -s "https://en.wikipedia.org/w/api.php?action=query&list=search&srsearch=Islam+Freemasonry+Muslim&format=json"

# Full article text
curl -s "https://en.wikipedia.org/w/api.php?action=parse&page=Muhammad_Abduh&prop=text&format=json" \
  | python3 -c "import sys,json,re,html; ..."
```

Key pages: Muhammad_Abduh, Emir_Abdelkader, Freemasonry_in_Turkey, Freemasonry_in_the_Middle_East

## Full Research Chain (this session's proven workflow)

1. **Wikipedia API** → historical figures, country-level lodge status
2. **jina.ai** → extract full article text from Wikipedia and academic sources
3. **Camofox + DDG `site:` search + screenshot** → discover correct fatwa answer IDs on JS-routed sites
4. **jina.ai on correct URLs** → extract fatwa text
5. **Camofox screenshot + vision_analyze** → fallback for content jina.ai can't extract
6. **Google Scholar** → blocked (403), skip for anonymous extraction
