Skip to main content

No project description provided

Project description

Chrome API Python Client

Repository này chứa một bộ công cụ Python mạnh mẽ để tương tác với trình duyệt Chrome thông qua Selenium. Các công cụ bao gồm việc kết nối đến trình duyệt, kiểm soát các hành động tự động, xử lý proxy, và nhiều chức năng hữu ích khác liên quan đến việc tự động hóa trình duyệt.

Cài đặt

Để sử dụng client này, bạn cần cài đặt các thư viện yêu cầu. Bạn có thể cài đặt chúng bằng pip:

pip install selenium requests colorama opencv-python

Cấu hình

Để sử dụng các hàm trong chromeAPI.py, bạn cần đảm bảo rằng bạn có sẵn ChromeDriver phù hợp với phiên bản Chrome của mình.

Bạn có thể kết nối với trình duyệt Chrome như sau:

from chromeAPI import ChromeAPI

# Kết nối đến một phiên bản Chrome đang chạy trên cổng từ xa
browser = ChromeAPI.connect('path/to/chromedriver', remotePort=9222)

Chức năng

1. Mở Chrome với Selenium

Chức năng: Mở trình duyệt Chrome với một số tùy chọn cấu hình.

from chromeAPI import open_chrome_selenium

browser = open_chrome_selenium(userdatadir="path_to_user_data_dir", vi_tri=0, extensions="path_to_extension")
Name Type Required Description
userdatadir string yes Đường dẫn đến thư mục dữ liệu người dùng của Chrome
vi_tri int yes Vị trí cửa sổ Chrome
extensions string no Đường dẫn đến các extension của Chrome

2. Thao tác với trình duyệt

Chức năng: Thực hiện các thao tác như tìm kiếm, đợi, và tương tác với các phần tử trên trang web.

from chromeAPI import function_chrome
from selenium.webdriver.common.by import By

driver = function_chrome(browser)
element = driver.wait_element(By.ID, "example_id")
Name Type Required Description
browser object yes Đối tượng trình duyệt (webdriver.Chrome instance)
vi_tri int no Vị trí cửa sổ Chrome
delay int no Thời gian chờ đợi trước khi thao tác (mặc định: 10 giây)

Các chức năng chính:

  • wait_element: Đợi và tìm một phần tử trên trang web.
  • find_element_by_text: Tìm một phần tử theo văn bản.
  • send_keys: Gửi các ký tự vào một phần tử input.

3. Sử dụng Proxy

Các loại proxy được hỗ trợ:

Name Type Required Description
tinsoft API yes API proxy của tinsoft
tmproxy API yes API proxy của tmproxy
wwproxy API yes API proxy của wwproxy
dtproxy API yes API proxy của dtproxy
proxyv6 API yes API proxy của proxyv6

4. Tạo Email tạm thời và nhận OTP

Chức năng: Tạo email tạm thời và lấy mã OTP.

from chromeAPI import mailtm

email_service = mailtm()
email, headers = email_service.creat_email()
otp = email_service.get_otp(content="Your OTP is", otp=True)
Name Type Required Description
dot string no Domain sử dụng cho email tạm thời (mặc định: "gw")
proxy string no Địa chỉ proxy nếu sử dụng
content string yes Nội dung để tìm kiếm OTP trong email
otp bool no Trả về mã OTP là 4 hoặc 6 số (mặc định: True)

Các phương thức chính:

  • creat_email: Tạo email tạm thời.
  • get_otp: Lấy mã OTP từ email.

5. Xử lý File và Thư mục

Chức năng: Xử lý file và thư mục như tạo, đọc, ghi và xóa file/thư mục.

from chromeAPI import scr_file

# Kiểm tra và tạo file nếu chưa tồn tại
scr_file.check_exist('path_to_file')

# Đọc nội dung file
content = scr_file.read_file('path_to_file')
Name Type Required Description
path_file string yes Đường dẫn đến file để kiểm tra hoặc tạo mới
content string yes Nội dung để ghi vào file
mode string no Chế độ mở file (mặc định: 'a+')

Các chức năng chính:

  • check_exist: Kiểm tra và tạo file.
  • write: Ghi dữ liệu vào file.
  • read_file: Đọc dữ liệu từ file.

Xử lý lỗi

Nếu có bất kỳ lỗi nào xảy ra trong quá trình sử dụng các hàm, các lỗi sẽ được xử lý thông qua các thông báo lỗi chi tiết. Đảm bảo bạn kiểm tra kỹ log để biết nguyên nhân và cách khắc phục.

Giấy phép

Dự án này được cấp phép theo Giấy phép MIT - xem tệp LICENSE để biết thêm chi tiết.

Liên hệ

Đối với bất kỳ yêu cầu hoặc vấn đề nào, vui lòng liên hệ hỗ trợ tại ChromeAPI Support.

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

chromeapi-0.2.2.tar.gz (14.0 kB view details)

Uploaded Source

Built Distribution

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

chromeAPI-0.2.2-py3-none-any.whl (21.4 kB view details)

Uploaded Python 3

File details

Details for the file chromeapi-0.2.2.tar.gz.

File metadata

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

File hashes

Hashes for chromeapi-0.2.2.tar.gz
Algorithm Hash digest
SHA256 1df759335d74a8e7aa68290d785165814358a53c1951ba9dd0af2a1832a56944
MD5 419b4c982e8866def6d2eba651f9bee5
BLAKE2b-256 558075195918e9f4dad1cd360739f46296e4c6588f8c41b0a8aa7aed9243510e

See more details on using hashes here.

File details

Details for the file chromeAPI-0.2.2-py3-none-any.whl.

File metadata

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

File hashes

Hashes for chromeAPI-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 4bdfb1b51096863f498863dda0ef5852034dc1602321b1c716be25e7acaf80ed
MD5 95a4ca835d997562c3d83953dca31263
BLAKE2b-256 92d77b2dad96f7124c1638277988da5712c70c16fddd6a467d21f56fa0e65b6d

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