Metadata-Version: 2.4
Name: olj-cli
Version: 0.3.0
Summary: A command-line tool to automate job applications and scraping on OnlineJobs.ph
Author-email: kuugang <jakebajo21@gmail.com>
License: MIT License
        
        Copyright (c) 2026 Kuugang
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Repository, https://github.com/Kuugang/olj-cli
Project-URL: Homepage, https://github.com/Kuugang/olj-cli
Project-URL: Bug Tracker, https://github.com/Kuugang/olj-cli/issues
Keywords: cli,automation,scraping,jobsearch,onlinejobs
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: Intended Audience :: End Users/Desktop
Classifier: Natural Language :: English
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Topic :: Office/Business
Classifier: Topic :: Utilities
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: beautifulsoup4>=4.14.3
Requires-Dist: curl-cffi>=0.15.0
Requires-Dist: requests>=2.33.1
Dynamic: license-file

# OnlineJobs.ph CLI

A command-line tool to automate job applications and scraping on [OnlineJobs.ph](https://www.onlinejobs.ph).

## Features

- **Login**: Authenticate with OnlineJobs.ph and export session cookies
- **Apply**: Automatically apply to job postings with custom messages and contact info
- **Jobs**: Search and scrape job listings with descriptions
- **Proxy Support**: Route requests through HTTP/HTTPS proxies (with optional authentication)

## Installation

### Requirements

- Python 3.11+

### Option 1: Install from PyPI (Recommended)

```bash
pip install olj-cli
```

This will install the `olj-cli` command-line tool globally.

### Option 2: Clone and Install from Source

```bash
git clone https://github.com/Kuugang/olj-cli.git
cd olj-cli
pip install -e .
```

This will install the package in development mode.

## Example Usage

### 1. Login — Get Session Cookies

Authenticate and save your session cookies for use in other commands.

```bash
COOKIES=$(olj-cli login --email you@example.com --password secret)
```

This prints the cookies as JSON to stdout, which you can store in the `COOKIES` variable.

### 2. Apply to a Job

Submit an application to a specific job posting.

```bash
olj-cli apply \
  --cookies "$COOKIES" \
  --job-url "https://www.onlinejobs.ph/jobseekers/job/1604447" \
  --subject "Applying for Senior Developer" \
  --message "I would like to apply, thank you." \
  --contact-info "Email: you@example.com | GitHub: yourhandle"
```

**Parameters:**

- `--cookies`: JSON cookies string from the `login` command
- `--job-url`: Full URL of the job posting
- `--subject`: Email subject line
- `--message`: Email message body
- `--contact-info`: Your contact information
- `--apply-points` (optional): Points to spend (default: 1)

### 3. Scrape Jobs

Search and scrape job listings with full descriptions.

```bash
olj-cli jobs --filter "python developer"        # Scrape first page only
olj-cli jobs --filter "python developer" --all  # Scrape all pages
olj-cli jobs --all --page 2                     # Start from page 2 and scrape all
```

**Parameters:**

- `--filter` (optional): Keyword filter for search
- `--page` (optional): Starting page number (default: 1)
- `--all` (optional): Scrape all pages until no jobs found (default: only first page)

**Output:** JSON array of jobs with `url`, `title`, `posted_by`, `posted_on`, `rate`, and `description`

## Commands

All commands support the `--proxy` option for routing through proxies.

### `login`

Authenticate with OnlineJobs.ph and output session cookies as JSON.

```bash
olj-cli [--proxy <proxy>] login --email <email> --password <password>
```

**Environment Variables:**

- `OLJ_EMAIL`: Account email (alternative to `--email`)
- `OLJ_PASSWORD`: Account password (alternative to `--password`)

### `apply`

Apply to a job posting using authenticated session.

```bash
olj-cli [--proxy <proxy>] apply --cookies <JSON> --job-url <url> --subject <subject> --message <message> --contact-info <info>
```

### `jobs`

Search and scrape job listings.

```bash
olj-cli [--proxy <proxy>] jobs [--filter <keyword>] [--page <number>] [--all]
```

## Proxy Configuration

All commands support HTTP/HTTPS proxies. Use the `--proxy` argument in format:

- **Without authentication**: `host:port`
- **With authentication**: `host:port:username:password`

### Examples

```bash
# Login through proxy (no auth)
olj-cli --proxy "proxy.example.com:8080" login --email you@example.com --password secret

# Apply to job through authenticated proxy
olj-cli --proxy "proxy.example.com:8080:user:pass" apply \
  --cookies "$COOKIES" \
  --job-url "https://www.onlinejobs.ph/jobseekers/job/1604447" \
  --subject "Applying for Senior Developer" \
  --message "I would like to apply, thank you." \
  --contact-info "Email: you@example.com | GitHub: yourhandle"

# Scrape jobs through proxy
olj-cli --proxy "10.0.0.1:3128:admin:password123" jobs --filter "python" --all
```

## Debug

Enable debug logging for any command:

```bash
olj-cli --debug jobs --filter "react"
```

## Example Workflow

```bash
# 1. Search for jobs (no authentication needed)
olj-cli jobs --filter "python developer" --all

# 2. Login to get cookies (if you want to apply)
COOKIES=$(olj-cli login --email you@example.com --password secret)

# 3. Apply to a specific job
olj-cli apply \
  --cookies "$COOKIES" \
  --job-url "https://www.onlinejobs.ph/jobseekers/job/1604447" \
  --subject "Applying for Senior Developer" \
  --message "I would like to apply, thank you." \
  --contact-info "Email: you@example.com | GitHub: yourhandle"
```

## How It Works

### Login Flow

1. Fetches the login page to extract CSRF token
2. Submits credentials to authenticate endpoint
3. Stores session cookies for subsequent requests

### Apply Flow

1. Fetches the job posting page
2. Extracts CSRF token, job ID, and other metadata
3. Fetches the application form
4. Submits the application with subject, message, and contact info

### Jobs Scraping

1. Fetches job listing pages with optional keyword filter
2. Parses job cards to extract title, URL, poster, and date
3. Fetches each job's detail page to extract full description
4. Returns complete job data as JSON
