fix: use MediaWiki API for wiki scraping to bypass Cloudflare

Direct wiki page requests return 403 due to Cloudflare JS challenge.
Switch to MediaWiki parse API which returns rendered HTML without
blocking. Also match img[alt='Official'] in lane detection.
This commit is contained in:
tiennm99 committed 2026-04-05 00:14:13 +07:00
1 parent 090082a51d
commit 23be5513e4
5 files changed
+572 -212

No files matched your search

+15 -17
View File
@@ -20,14 +20,23 @@ func TestDdragonAPI(t *testing.T) {
}
}
func TestWikiDraftPosition(t *testing.T) {
resp, err := http.Get(wikiDraftPositionURL)
func TestWikiAPIChampionList(t *testing.T) {
doc, err := fetchWikiDoc("List_of_champions")
if err != nil {
t.Fatalf("request failed: %v", err)
t.Fatalf("fetch failed: %v", err)
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
t.Fatalf("expected 200, got %d", resp.StatusCode)
if doc.Find("tbody").Length() == 0 {
t.Fatal("expected at least one tbody in champion list")
}
}
func TestWikiAPIDraftPosition(t *testing.T) {
doc, err := fetchWikiDoc("List_of_champions_by_draft_position")
if err != nil {
t.Fatalf("fetch failed: %v", err)
}
if doc.Find("tbody").Length() < 2 {
t.Fatal("expected at least two tbody in draft position page")
}
}
@@ -46,14 +55,3 @@ func TestRegionAPI(t *testing.T) {
t.Fatalf("expected application/json, got %s", ct)
}
}
func TestWikiChampionList(t *testing.T) {
resp, err := http.Get(wikiChampionListURL)
if err != nil {
t.Fatalf("request failed: %v", err)
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
t.Fatalf("expected 200, got %d", resp.StatusCode)
}
}