Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Cloudflare protection. (TypeError: Cannot find function observe.)

Aperta
#1,136 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
45/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
java
Ambito
backend, web-dev

Direzione di ricerca

Start by examining the attached log.txt and cloudflare.xml alongside the reported HtmlUnit 5.1.0 setup and the Cloudflare response from the example URL. The issue does not name source files or tests, so first trace how HtmlUnit handles the reported JavaScript error, TypeError: Cannot find function observe. Done means identifying whether this is an HtmlUnit issue and, if so, reproducing and fixing it with a regression test.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Hello, I'm trying to download a jar file from the website www.spigotmc.org , but I'm having trouble getting through Cloudflare's protection

My code:

import org.htmlunit.CookieManager;
import org.htmlunit.NicelyResynchronizingAjaxController;
import org.htmlunit.WebClient;
import org.htmlunit.html.HtmlPage;
import org.junit.jupiter.api.Test;

public class NetworksUtilTest
{
    private static final WebClient webClient = new WebClient();

    @Test
    void htmlUnitTest() throws Exception
    {
        webClient.addRequestHeader("Connection", "keep-alive");
        webClient.addRequestHeader("Upgrade-Insecure-Requests", "1");
        webClient.addRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.86 Safari/537.36");
        webClient.addRequestHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8");
        webClient.addRequestHeader("Accept-Language", "en-US,en;q=0.9");
        webClient.addRequestHeader("Accept-Encoding", "gzip, deflate");

        webClient.getOptions().setThrowExceptionOnFailingStatusCode(false);
        webClient.getOptions().setThrowExceptionOnScriptError(false);
        webClient.getOptions().setFetchPolyfillEnabled(true);
        webClient.getOptions().setPopupBlockerEnabled(true);
	    webClient.getOptions().setGeolocationEnabled(false);
        webClient.getOptions().setJavaScriptEnabled(true);
        webClient.getOptions().setDoNotTrackEnabled(true);
        webClient.getOptions().setRedirectEnabled(true);
        webClient.getOptions().setDownloadImages(false);
        webClient.getOptions().setUseInsecureSSL(true);
        webClient.getOptions().setScreenHeight(768);
        webClient.getOptions().setScreenWidth(1366);
        webClient.getOptions().setCssEnabled(false);
	    webClient.getOptions().setTimeout(5000);

        CookieManager cookieManager = new CookieManager();
        webClient.setCookieManager(cookieManager);

        webClient.setAjaxController(new NicelyResynchronizingAjaxController());
        webClient.setAlertHandler((page, message) -> System.err.println("[alert] " + message)); // to be changed
        webClient.setJavaScriptTimeout(5000);
        webClient.getCookieManager().setCookiesEnabled(true);
        webClient.getCache().setMaxSize(1);

        HtmlPage htmlCloudflarePage = webClient.getPage("https://www.spigotmc.org/resources/vault.34315/download?version=344916");
        webClient.waitForBackgroundJavaScript(5_000);
        System.out.println(htmlCloudflarePage.getWebResponse().getResponseHeaderValue("Content-Type"));

        webClient.close();
    }
}

logs: log.txt

Gradle Version: gradle-9.5.1
HtmlUnit Version: 5.1.0

Update (10.08.2026)

XML Response: cloudflare.xml

Lingua principale
JavaScript
Stelle
952
Fork
183
Merge medio
2g 1h
PR unite (30g)
1

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di HtmlUnit/htmlunit

Tutte le issue di HtmlUnit/htmlunit

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.