Skip to main content

Uma biblioteca para buscar e extrair dados do site 'Toda Matéria'.

Project description

LearnFetch

LearnFetch is a Python library designed to search and extract data from the 'Toda Materia' website. It is useful for accessing information from articles and educational content programmatically.

Installation

To install LearnFetch, use pip. Make sure you have Python 3.12.3 or higher installed.

pip install LearnFetch

Usage

Importing the Library

To get started with the library, import the Pesquisador class:

from learnfetch import Pesquisador

Creating an Instance and Performing a Search

Create an instance of the Pesquisador class and use the get_response method to perform searches:

# Creating an instance of the Pesquisador class
researcher = Pesquisador()

# Performing a search
results = researcher.get_response("Photosynthesis")

# Displaying the results
print(results)

Package Structure

The package structure includes:

  • learnfetch/: Directory containing the package with the pesquisador.py module.

    • __init__.py: File that makes the directory a Python package.
    • pesquisador.py: Contains the Pesquisador class with methods for searching and extracting data.
  • tests/: Directory for unit tests.

    • __init__.py: File that makes the directory a Python package.
    • test_pesquisador.py: File containing tests for the Pesquisador class.

Complete Example

Here is a complete example of using the library:

from learnfetch import Pesquisador

# Criando uma instância da classe Pesquisador
pesquisador = Pesquisador()

# Realizando uma busca
resultados = pesquisador.get_response("Redes neurais")

# Pegando um determinado dicionário da lista (por exemplo, o segundo)
if len(resultados) > 1:
        segundo_dicionario = resultados[1] 

        # Pegando um valor específico dentro de um dicionário
        conteudo = segundo_dicionario.get("content")
        print("Conteudo do Segundo Dicionário:")
        print(conteudo)

Another

    from learnfetch import Pesquisador
    # O uso de docx é opcional, estou usando somente para desmostrar umas das utilidades da biblioteca
    from docx import Document

    # Criar uma instância da classe Pesquisador
    researcher = Pesquisador()

    # Realizar uma busca
    termo_de_busca = "Fotossíntese"
    resultados = researcher.get_response(termo_de_busca)

    # Função para criar uma ficha de leitura para cada item
    def adicionar_ficha_ao_documento(doc, titulo, conteudo):
        doc.add_heading('Ficha de Leitura', level=1)
        doc.add_heading('Título:', level=2)
        doc.add_paragraph(titulo)
        doc.add_heading('Resumo:', level=2)
        doc.add_paragraph(conteudo)
        doc.add_heading('Comentários:', level=2)
        doc.add_paragraph('Adicione aqui suas observações pessoais.')
        doc.add_heading('Questões levantadas:', level=2)
        doc.add_paragraph('Liste aqui as questões ou dúvidas surgidas durante a leitura.')
        doc.add_paragraph("\n" + "="*50 + "\n")

    # Criar um documento Word
    documento = Document()

    # Verificar se a chave 'results' está presente no dicionário retornado
    if resultados:
        # Iterar sobre cada item na lista de resultados
        for item in resultados:
            titulo = item.get('title', 'Título não encontrado')
            conteudo = item.get('content', 'Conteúdo não encontrado')
            adicionar_ficha_ao_documento(documento, titulo, conteudo)
    else:
        print("Nenhum resultado encontrado.")

    # Salvar o documento
    nome_arquivo = f'ficha sobre {termo_de_busca}.docx'
    documento.save(nome_arquivo)
    print(f"As fichas de leitura foram salvas no arquivo {nome_arquivo}.")

Contributing

If you would like to contribute to the project, feel free to open an issue or submit a pull request on the GitHub repository.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contact

For any questions or suggestions, you can reach out to:

Explanation of Sections:

  1. Introduction: Describes the purpose of the library.
  2. Installation: Instructions for installing the library using pip.
  3. Usage: Examples of how to import, create an instance, and use the library.
  4. Package Structure: Explains the structure of the package directories and files.
  5. Complete Example: A detailed example of how to use the library.
  6. Contributing: Information on how to contribute to the project.
  7. License: Details about the project license.
  8. Contact: Contact information for support and suggestions.

Make sure to adjust the content as needed to reflect the specifics of your project.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

learnfetch-1.0.1.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

LearnFetch-1.0.1-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file learnfetch-1.0.1.tar.gz.

File metadata

  • Download URL: learnfetch-1.0.1.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.3

File hashes

Hashes for learnfetch-1.0.1.tar.gz
Algorithm Hash digest
SHA256 67469ab807bd8baab1a76c049fe74bbe934c67152083eef77ca362e41e3eb635
MD5 d51c1900db6894bb5e418c91222b2008
BLAKE2b-256 61635df47de5c8b9ab5ba11ecd58d443eeeb45c1fd917570dc742eca6fe5071f

See more details on using hashes here.

File details

Details for the file LearnFetch-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: LearnFetch-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.3

File hashes

Hashes for LearnFetch-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8e8d07c669b04258d6ecfbd6280644d185cdb97d077943e44aa853ff39b0ac66
MD5 1c8e4005cccd4ef73676a5cb8cf6ccf1
BLAKE2b-256 7749059b1656868f9e8245d560cca993689df9fc21c3df63ce3d4666fd760217

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page