Skip to main content

Add your description here

Project description

Job Crawler: Thư viện hỗ trợ cào data về các ngành nghề

Cách cài đặt

Cách 1: tải từ repo

git clone repo_url
pip install -e .

Cách 2: từ PyPi

pip install ghibli_job_crawler

Một số yêu cầu trước

Có thể cài playwright và chronium theo hướng dẫn trong docs

Cài đặt environment variables

Thư viên hỗ trợ 3 thư viện Sqlite, MySQL, PostgresSQL

Để kết nối với Sqlite, đặt trong file .env như ví dụ dưới:

DB_TYPE="sqlite"
DB_PATH="data/test.sqlite"

Còn với MySQL và PostgreSQL:

# MySQL
DB_TYPE=YOUR_DB_TYPE
DB_HOST=YOUR_DB_HOST
DB_USERNAME=YOUR_DB_USERNAME
DB_PASSWORD=YOUR_DB_PASSWORD
DB_NAME=YOUR_DB_NAME
DB_PORT=YOUR_DB_PORT

# PostgresSQL
DB_TYPE=YOUR_DB_TYPE
DB_HOST=YOUR_DB_HOST
DB_USERNAME=YOUR_DB_USERNAME
DB_PASSWORD=YOUR_DB_PASSWORD
DB_NAME=YOUR_DB_NAME
DB_PORT=YOUR_DB_PORT

Với DB_PORT thì có thể có hoặc không, mặc sẽ cấu hình đúng với port của database.

Cách sử dụng đơn giản

Đầu tiên, bạn phải khởi tạo database, thư viện hỗ trợ tạo database mặc định để hỗ trợ cào, để làm vậy thì xem bên dưới:

from job_crawler.database import init_database

init_database()

Nếu bạn có sẵn data thì có thể import vào.

Trong module job_crawler.database.handler có chứa các hàm hỗ trợ truy vấn cơ sở dữ liệu, bạn có thể tham khảo các hàm đó trong code.

Để gọi đối tượng cào, thì bạn có thể gọi như sau:

Cào TopCV

from job_crawler.topcv import TopCVCrawler

print("TopCV Job Crawler (Optimized)")
crawler = TopCVCrawler(max_workers=3)
try:
    crawler.crawl_jobs(start_page=1, end_page=1)
    print("\nHoàn thành crawl từ TopCV!")
except KeyboardInterrupt:
    crawler.stop()
    print("\nĐã dừng crawler theo yêu cầu người dùng.")
except Exception as e:
    print(f"\nLỗi trong quá trình crawl: {str(e)}")

Cào VietnamWorks

from job_crawler.vietnamworks import VietnamWorksCrawler

print("VietnamWorks Job Crawler (Optimized)")
crawler = VietnamWorksCrawler(max_workers=3)
try:
    crawler.crawl_jobs(start_page=0, end_page=1)
    print("\nHoàn thành crawl từ TopCV!")
except KeyboardInterrupt:
    crawler.stop()
    print("\nĐã dừng crawler theo yêu cầu người dùng.")
except Exception as e:
    print(f"\nLỗi trong quá trình crawl: {str(e)}")

Cào trang tuy chỉnh Trước tiên bạn cần phải tạo file configuration trước, ví dụ mình để trong thư mục configs. Sau đó gọi:

from job_crawler.generic_job import GenericJobCrawler

crawler = GenericJobCrawler(config_path, max_workers=max_workers)
try:
    crawler.crawl_jobs(start_page=start_page, end_page=end_page)
    print("\nHoàn thành crawl!")
except KeyboardInterrupt:
    crawler.stop()
    print("\nĐã dừng crawler theo yêu cầu người dùng.")

Cào bằng Gemini Để cào bằng gemini thì phải bỏ API key vào file .env trước

GOOOGLE_API_KEY=YOUR_GOOGLE_API_KEY

Sử dụng cli

job-crawler crawl --type topcv --max-workers 3 --start-page 0 --end-page 1
job-crawler crawl --type generic_job --config config/config.json --max-workers 3 --start-page 0 --end-page 1
job-crawler export --type csv --save-path data/test_csv --table-name Job Company
job-crawler export --type json --save-path data/test_csv --table-name Job Company

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

ghibli_job_crawler-0.2.0.tar.gz (35.7 kB view details)

Uploaded Source

Built Distribution

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

ghibli_job_crawler-0.2.0-py3-none-any.whl (41.3 kB view details)

Uploaded Python 3

File details

Details for the file ghibli_job_crawler-0.2.0.tar.gz.

File metadata

  • Download URL: ghibli_job_crawler-0.2.0.tar.gz
  • Upload date:
  • Size: 35.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for ghibli_job_crawler-0.2.0.tar.gz
Algorithm Hash digest
SHA256 aa6a05904b9223dbb2297e9b057f6977aeadb3127cb1369b4fd98fed2e432d0c
MD5 002fe3b46890f2a6d5aaa95842cf8762
BLAKE2b-256 2ef0bbf2c08ac1fb61617624be98bac31450514fdd2a3f5a4388a65d603cb2e2

See more details on using hashes here.

File details

Details for the file ghibli_job_crawler-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for ghibli_job_crawler-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0e06e1662181f330aca7e4ae36b367367059e34b8d016a0458e12ff7d36f6695
MD5 fd1701629b6cced174bb7e16e44cc0ca
BLAKE2b-256 e73c0f722829fa0fcc2dad51ef20905644357df135d1bdbc41baa849e6c1346f

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