Metadata-Version: 2.1
Name: botweb
Version: 0.1.0
Summary: Class to perform web selenium and requests operations on web systems
Home-page: https://github.com/botlorien/botweb
Author: Ben-Hur P. B. Santos
Author-email: botlorien@gmail.com
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE

# BotWeb

BotWeb Ã© uma ferramenta poderosa para automaÃ§Ã£o de operaÃ§Ãµes web, combinando as bibliotecas Selenium e Requests. Este projeto foi projetado para simplificar tarefas como scraping de dados, interaÃ§Ãµes em sites e testes automatizados.

## Funcionalidades

- **AutomatizaÃ§Ã£o com Selenium:** Controle completo de navegadores para interagir com elementos de pÃ¡ginas web.
- **RequisiÃ§Ãµes HTTP com Requests:** Realize requisiÃ§Ãµes GET, POST e outras operaÃ§Ãµes HTTP.
- **IntegraÃ§Ã£o entre Selenium e Requests:** Flexibilidade para usar o melhor das duas bibliotecas em suas operaÃ§Ãµes web.

## Requisitos

- Python 3.10 ou superior.
- Navegador compatÃ­vel com o Selenium (ex.: Chrome, Firefox, Edge).

## InstalaÃ§Ã£o

### Passo 1: Instalar o Pacote

Para instalar o pacote, execute:

```bash
pip install botweb
```

## Exemplo de Uso

```python
from botweb import BotWeb


class MyBot(BotWeb):
    def __init__(self, *args, **kwargs):
        super().__init__(
            # The prefix name to be concatenated with the credentials_keys
            # eg. WEB_SYSTEM_USERNAME, WEB_SYSTEM_PASSWORD
            # these variables will be setted as environment variables
            # with the values asked from the terminal.
            # To prevent of every run ask the credentials from the terminal
            # restart the IDE after provide the credentials values
            prefix_env="WEB_SYSTEM",
            credentials_keys=["USERNAME", "PASSWORD"]
            )

    def login(self):
        """My login logic here! (Abstract method needs to be implemented)"""
        # self._enter_username(self.credentials['USERNAME'])
        # self._enter_password(self.credentials['PASSWORD'])
        # self._submit()

        # This method sets the cookies into the self.session: requests.Session
        # It enable making requests inside the system
        # see the post_example() method bellow
        self.get_cookies()

    def post_example(self):
        # The headers inspected from the network request
        headers = {
            "accept": "application/json, text/plain, */*",
            "accept-language": "pt-BR,pt;q=0.9,en-US;q=0.8,en;q=0.7",
            "authorization": "",
            "content-type": "application/json;charset=UTF-8",
        }

        # If the system store the token in the local storage it would work,
        # else override it with your own logic to get the token authorization
        headers.update({
            "authorization": self.get_token_authorization_from_storage()
            })

        # The payload inspected from the network request
        body = 'a=something&b=anotherthing'
        response = self.session.post(
            "https://example.com.br",
            headers=headers,
            data=body,
        )
        if response.status_code == 200:
            print(response.json())


if __name__ == '__main__':
    with MyBot() as mybot:
        mybot.init_browser(headless=False, browser="firefox")
        mybot.open(
            "https://github.com/login"
        )
        mybot.login()
        # mybot.post_example()
        input("Digite algo para continuar...")

```

## ContribuiÃ§Ãµes

ContribuiÃ§Ãµes sÃ£o bem-vindas! Para contribuir:

1. Fork este repositÃ³rio.
2. Crie um branch para sua funcionalidade ou correÃ§Ã£o:
   ```bash
   git checkout -b minha-funcionalidade
   ```
3. Envie suas alteraÃ§Ãµes:
   ```bash
   git commit -m "Adiciona nova funcionalidade"
   ```
4. Submeta um pull request.

## LicenÃ§a

Este projeto estÃ¡ licenciado sob a [LicenÃ§a MIT](LICENSE).

## Contato

Para mais informaÃ§Ãµes ou suporte, visite o [repositÃ³rio no GitHub](https://github.com/botlorien/botweb).

