Skip to content

Latest commit

 

History

History
50 lines (39 loc) · 3.29 KB

File metadata and controls

50 lines (39 loc) · 3.29 KB

Thank you for the clarifications. Let's refine the state machine based on your feedback:

  1. Timeouts:

    • Use the term "timeout" instead of "stopwatch" for clarity.
    • Start the timeout when waiting for elements to appear or become clickable.
    • Read the timeout values from the .ini file before clicking the "next" or "previous" button to allow for dynamic updates.
  2. Button states and actions:

    • Check for the presence and state of the "next" and "previous" buttons using their respective class names and IDs.
    • Consider the "next" button active if it has the class "btn btn-default btn-xs", the ID "btnnextpage", and the onclick attribute "nextpage()".
    • Consider the "previous" button inactive if it has the class "btn btn-default btn-xs", the ID "btnprepage", the onclick attribute "prepage()", and the disabled attribute "disabled". 'previous' active button קודם button 'next' inactive'
    • If the "Ok" button is not found, proceed to check for the existence of data and scrape it if present, then click the "next" button.
  3. Simplified error handling:

    • If an unrecoverable error occurs, such as the absence of actionable elements or the inability to proceed, halt the scraping process.
  4. Database handling:

    • Rely on the database to handle itself, assuming it has proper error handling and self-management capabilities.
  5. "page_reload" function:

    • If the "back" button is not found or not clickable, halt the scraping process.
  6. Unrecoverable errors:

    • Define an unrecoverable error as a situation where no action is possible, such as the absence of required elements or the inability to proceed.
    • In case of an unrecoverable error, halt the scraping process.
  7. Logging:

    • Simplify logging and focus on capturing essential information for debugging and monitoring purposes.

Refined State Machine:

  1. Start the scraping process.
  2. Check if the current page has an active "Ok" button. If found, click it and proceed to step 3. If not found, proceed to step 3.
  3. Check if the current page has data and an active "next" button.
    • If data is found, scrape it.
    • If the "next" button is active, read the timeout value from the .ini file, wait for the specified timeout, and click the "next" button. Proceed to step 2.
    • If data is not found and the "previous" button is active, click the "previous" button and proceed to step 4.
    • If data is not found and the "previous" button is inactive or not found, halt the scraping process.
  4. Wait for the specified timeout for elements to appear or become clickable.
    • If elements are found within the timeout, proceed to step 2.
    • If elements are not found within the timeout, halt the scraping process.

Additional considerations:

  • Handle pagination by clicking the "next" button until it becomes inactive or the last page is reached.
  • If any unrecoverable errors occur, such as the absence of required elements or the inability to proceed, halt the scraping process.
  • Implement simple logging to capture essential information for debugging and monitoring purposes.

This refined state machine simplifies the scraping process, focuses on the key actions and conditions, and incorporates your feedback regarding button states, error handling, and logging.