Skip to content

a tool to use headless_chrome to get the flow margin automatically for personal usage.

Notifications You must be signed in to change notification settings

Xhen-Starry-Night/flow_margin_getter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Telecom Data Usage Extractor

This project uses Puppeteer to automate the process of logging into a telecom service website and extracting data usage information.

Features

  • Automatically navigates to the login page
  • Fills in the phone number (removed for privacy)
  • Clicks the login button with a delay before clicking to ensure proper page state
  • Waits for the information page to load
  • Extracts package information including:
    • Package name
    • Used data amount
    • Remaining data amount
    • Total package data
  • Includes retry mechanisms for robust operation

Technical Details

The script handles:

  • Dynamic content loading with proper waits
  • Complex selectors for uni-app framework elements
  • Data extraction from specific DOM elements
  • Retry mechanisms with configurable attempts and delays
  • 50ms delay after filling the phone number before clicking login to allow UI updates
  • Proper error handling and cleanup

Usage

Run the script with:

node project_files/extract_usage.js

Output Format

The script outputs package information in a structured format:

=== PACKAGE INFORMATION ===
Package Name: 1G流量年卡套餐
Used Data: 17.26MB
Remaining Data: 0.98GB
Total Package: 1.00GB
=========================

Dependencies

  • puppeteer (for browser automation)
  • Chromium (installed separately on the system at /usr/sbin/chromium)

Retry Mechanisms

The script implements retry logic for key operations:

  1. Filling Phone Number: Up to 3 attempts with 2-second delays
  2. Clicking Login Button: Up to 3 attempts with 2-second delays
  3. Loading Information Page: Up to 3 attempts with 3-second delays

Each operation includes detailed logging to track attempts and success/failure status.

About

a tool to use headless_chrome to get the flow margin automatically for personal usage.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors