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.1.tar.gz (14.2 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.1-py3-none-any.whl (12.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: chromeapi-0.2.1.tar.gz
  • Upload date:
  • Size: 14.2 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.1.tar.gz
Algorithm Hash digest
SHA256 38aa7a89991d9450754b75782b1e786fae6b4345e7e8853cb8c2d742bab70612
MD5 175459994bdbde7deb2a7803ca04b2b4
BLAKE2b-256 9b14bf69e697a5462697f3bba9b8c1cb496a16d35cca7069ab7bf96950d5c49e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chromeAPI-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 12.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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a04d18a425f20b7addfbe7aad89476dc91598982cbeb454fa2ae24422f9291c2
MD5 668cc27760237d6aca405da00910c4f8
BLAKE2b-256 a14f805792cfeb641794d9ac963a91d8dc5ccc9609ce80c45c3aeb5eba436fdd

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