Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

225
Visualizações
ROME custom user agent/reading Reddit RSS

So I'm trying to make a Discord bot that uses a Reddit RSS feed to post some info about new posts. I'm making this in Java and am currently working on pulling the RSS feed. Trouble is, Reddit rejects whatever user agent ROME uses by default, I cannot seem to find a feasible alternative to ROME short of implementing one myself, and the only solution I can find to set a custom user agent in ROME uses a bunch of deprecated functionality. How do I set a custom user agent in ROME?

over 4 years ago · Santiago Trujillo
3 Respostas
Responde à pergunta

0

I fixed my own problem by simply grabbing a standard InputStream of the feed and building the feed through that with SyndFeed feed = input.build(new XmlReader(stream));

over 4 years ago · Santiago Trujillo Relatório

0

Does ROME allow for customizing the user agent?

If not, you should be able to make read-only JSON requests without needing authentication, for example "GET https://www.reddit.com/r/funny/new.json"

over 4 years ago · Santiago Trujillo Relatório

0

With Apache HttpClient 4 and Rome 1.7.0 you can set the user agent string like this:

CloseableHttpClient customClient = HttpClients.custom()
                    .setUserAgent("Your custom user agent string here")
                    .build();
String url = "http://stackoverflow.com/feeds/tag?tagnames=rome";
try (CloseableHttpClient client = customClient) {
    HttpUriRequest request = new HttpGet(url);
    try (CloseableHttpResponse response = client.execute(request);
        InputStream stream = response.getEntity().getContent()) {
        SyndFeedInput input = new SyndFeedInput();
        SyndFeed feed = input.build(new XmlReader(stream));
        System.out.println(feed.getTitle());
    }
}

It is more lines of code than before, but easier to configure. They've deprecated the old Rome Fetcher.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda