A client for interacting with PokerNow.club using Selenium.
- Installation
- Usage
- PokerClient
- GameStateManager
- ActionHelper
- ElementHelper
- Models
- CookieManager
- Support
- Contributing
- License
You can install the PokerNow Client using pip:
pip install PokerNow
Here's an example of how to use the PokerNow Client:
from selenium import webdriver
from pokernow import PokerClient
import time
# Create a new instance of a WebDriver
driver = webdriver.Firefox()
# Initialize the PokerClient with the driver and specify the cookie file path
client = PokerClient(driver, cookie_path='cookie_file.pkl')
# Navigate to the PokerNow.club login page
client.navigate('https://network.pokernow.club/sessions/new')
# Wait for the user to manually complete the login process and press Enter
input("Please complete the login process in the browser and press Enter to continue...")
# Save the cookies after successful login
client.cookie_manager.save_cookies()
# Navigate to a specific game or table (replace with your actual game link)
client.navigate('https://www.pokernow.club/games/pglev4PZzEvMv6DGgVNGbZz5J')
# Wait for the game to load
time.sleep(5)
# Retrieve the current game state
game_state = client.game_state_manager.get_game_state()
print("Game Type:", game_state.game_type)
print("Pot Size:", game_state.pot_size)
print("Community Cards:", [str(card) for card in game_state.community_cards])
print("Players:")
for player in game_state.players:
print(" Name:", player.name)
print(" Stack:", player.stack)
print(" Bet:", player.bet_value)
print(" Cards:", [str(card) for card in player.cards])
print(" Status:", player.status)
print(" Hand Message:", player.hand_message)
print("Dealer Position:", game_state.dealer_position)
print("Current Player:", game_state.current_player)
print("Blinds:", game_state.blinds)
print("Winners:")
for winner in game_state.winners:
print(" Name:", winner['name'])
print(" Stack Info:", winner['stack_info'])
print("Is Your Turn:", game_state.is_your_turn)
# Perform actions based on the game state and your strategy
available_actions = client.action_helper.get_available_actions()
print("Available Actions:", list(available_actions.keys()))
if 'Call' in available_actions:
client.action_helper.perform_action('Call')
elif 'Check' in available_actions:
client.action_helper.perform_action('Check')
elif 'Raise' in available_actions:
client.action_helper.perform_action('Raise', amount=100)
else:
client.action_helper.perform_action('Fold')
# Close the browser when finished
driver.quit()Make sure to have the appropriate WebDriver (e.g., ChromeDriver) installed and available in your system's PATH.
The PokerClient class is the main entry point for interacting with PokerNow.club.
def __init__(self, driver, cookie_path='pokernow_cookies.pkl')driver: The Selenium WebDriver instance.cookie_path(optional): The path to the cookie file for storing and loading cookies. Default is 'pokernow_cookies.pkl'.
navigate(url): Navigates to the specified URL.
The GameStateManager class is responsible for managing and retrieving the game state information.
def get_game_state(self)Retrieves the current game state, including game type, pot size, community cards, players' information, dealer position, current player, blinds, winners, and whether it's your turn.
def is_your_turn(self)Checks if it's your turn to act in the current game.
def get_winners(self)Retrieves the winners of the current hand, including their names and stack information.
def get_community_cards(self)Retrieves the community cards on the table.
def get_players_info(self)Retrieves information about all players at the table, including their names, stack sizes, bet values, cards, status, and hand messages.
def get_player_status(self, player_element)Determines the status of a player based on the player element.
def get_player_cards(self, player_element)Retrieves the cards of a player based on the player element.
def get_dealer_position(self)Retrieves the position of the dealer button.
def get_current_player(self)Retrieves the name of the current player.
def get_blinds(self)Retrieves the values of the blinds.
def parse_stack_value(self, stack_value)Parses the stack value string and returns the numeric value.
The ActionHelper class provides methods for interacting with the game and performing actions.
def get_available_actions(self)Retrieves the available actions for the current player.
def perform_action(self, action, amount=None)Performs the specified action (e.g., 'Call', 'Raise', 'Check', 'Fold') with an optional amount for raising.
def handle_raise(self, amount)Handles the raise action by entering the raise amount and confirming the bet.
def check_and_handle_fold_confirmation(self)Checks for a fold confirmation dialog and handles it if present.
The ElementHelper class provides utility methods for interacting with web elements using Selenium.
def wait_for_element(self, selector, timeout=10)Waits for an element to be present on the page within the specified timeout.
def is_element_present(self, selector)Checks if an element is present on the page.
def get_text(self, selector, context=None)Retrieves the text of an element specified by the selector, optionally within a specific context element.
def get_element(self, selector)Retrieves a single element specified by the selector.
def get_elements(self, selector)Retrieves multiple elements specified by the selector.
The models module contains data models used throughout the project.
Represents a playing card with rank and suit.
Represents the state of the game, including game type, pot size, community cards, players' information, dealer position, current player, blinds, winners, and whether it's your turn.
Represents information about a player, including name, stack size, bet value, cards, status, and hand message.
Enum representing the possible states of a player (CURRENT, FOLDED, OFFLINE, ACTIVE).
The CookieManager class handles loading and saving cookies for the PokerNow.club website.
def load_cookies(self)Loads cookies from the specified cookie file, if it exists.
def save_cookies(self)Saves the current cookies to the specified cookie file.
If you find this project helpful and would like to support its development, you can buy me a coffee at https://buymeacoffee.com/zehm. Your support is greatly appreciated!
Contributions are welcome! Please submit a pull request or open an issue on the GitHub repository.
This project is licensed under the MIT License. See the LICENSE file for more information.