mirror of
https://github.com/tiennm99/loldle.git
synced 2026-10-14 06:17:45 +00:00
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:
1 parent
090082a51d
commit
23be5513e4
5 files changed
+572
-212
No files matched your search
+15
-17
@@ -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)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user