Skip to content

This Android WebScraper class allows you to extract content from a web page using Java. It includes basic error handling and uses HttpURLConnection for web interactions.

License

Notifications You must be signed in to change notification settings

devicewhite/WebScraper-for-Java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

WebScraper-for-Java

English Tutorial: Web Scraper for Android

Introduction:

This Android WebScraper class allows you to extract content from a web page using Java. It includes basic error handling and uses HttpURLConnection for web interactions.

How to Use:

  1. Initialize WebScraper:

    WebScraper webScraper = new WebScraper("https://example.com");
  2. Get Web Page Content:

    String pageContent = webScraper.getContent();
  3. Find Patterns in Content:

    String[] patterns = webScraper.findWithPattern("<your-regex-pattern>");

Example Usage:

WebScraper webScraper = new WebScraper("https://example.com");
String pageContent = webScraper.getContent();

if (!pageContent.equals("(void)")) {
    Log.e("WebScraper", "Web Page Content:\n" + pageContent);

    String[] patterns = webScraper.findWithPattern("<your-regex-pattern>");
    Log.e("Matched Patterns:");
    for (String pattern : patterns) {
        Log.e(pattern);
    }
} else {
    Log.e("WebScraper", "Failed to fetch web page content.");
}

Note:

  • Ensure you have the internet permission in your AndroidManifest.xml file.

Tutorial em Português: Web Scraper para Android

Introdução:

Esta classe Android WebScraper permite extrair conteúdo de uma página da web usando Java. Inclui tratamento básico de erros e usa HttpURLConnection para interações web.

Como Usar:

  1. Inicializar o WebScraper:

    WebScraper webScraper = new WebScraper("https://example.com");
  2. Obter Conteúdo da Página Web:

    String pageContent = webScraper.getContent();
  3. Encontrar Padrões no Conteúdo:

    String[] patterns = webScraper.findWithPattern("<seu-padrao-de-regex>");

Exemplo de Uso:

WebScraper webScraper = new WebScraper("https://example.com");
String pageContent = webScraper.getContent();

if (!pageContent.equals("(void)")) {
    Log.e("WebScraper", "Conteúdo da Página Web:\n" + pageContent);

    String[] patterns = webScraper.findWithPattern("<seu-padrao-de-regex>");
    Log.e("Padrões Encontrados:");
    for (String pattern : patterns) {
        Log.e(pattern);
    }
} else {
    Log.e("WebScraper", "Falha ao obter o conteúdo da página web.");
}

Observação:

  • Certifique-se de ter a permissão de internet no arquivo AndroidManifest.xml.

About

This Android WebScraper class allows you to extract content from a web page using Java. It includes basic error handling and uses HttpURLConnection for web interactions.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages