"""A rendered page carrying Cloudflare's bot-detection beacon is not a challenge. Cloudflare injects an iframe loading /cdn-cgi/challenge-platform/scripts/jsd/main.js into every page a protected site serves. The raw HTML has no such reference; the browser adds it after load. FlareSolverr returns the rendered DOM, so every successful OceanofPDF solve came back carrying "/cdn-cgi/challenge-platform" and was rejected as an unsolved challenge - 26 KB results pages, retried five times each, then reported as unreachable. """ from shelfmark.bypass.challenge import challenge_marker # Shape of a rendered OceanofPDF search page: the site's own markup plus the beacon. RENDERED_PAGE_WITH_BEACON = ( "You searched for dune - OceanofPDF" 'Skip to main content' '
' '

Dune

' "
" "" '' "" ) # Cloudflare's managed challenge, trimmed to its markers. It can carry the beacon too. MANAGED_CHALLENGE = ( "Just a moment..." "" '' '' "" ) def test_beacon_on_a_rendered_page_is_not_a_challenge(): assert challenge_marker(RENDERED_PAGE_WITH_BEACON) is None def test_beacon_path_in_any_case_is_ignored(): assert challenge_marker(RENDERED_PAGE_WITH_BEACON.replace("scripts/jsd", "Scripts/JSD")) is None def test_managed_challenge_is_still_caught_with_the_beacon_present(): assert challenge_marker(MANAGED_CHALLENGE) is not None def test_challenge_script_path_alone_is_still_caught(): page = '' assert challenge_marker(page) == "/cdn-cgi/challenge-platform"