Package: ak_selenium
ak_seleniumSelenium package with requests integration and anti-bot detection measuresDocumentation·Report Bug·Request FeatureTable of Contents1. About the Project1.1. Features2. Getting Started2.1. Installation2.1.1. Production2.1.2. Development3. Usage3.1. Additional Options4. Roadmap5. License6. Contact7. Acknowledgements1. About the Projectak_seleniumis a Python package that provides an interface for automating browser tasks using Selenium. It comes with built-in functionalities for handling common tasks such as form filling, scrolling, and waiting for elements to load. Additionally, it has a built-in requests session that handles retries and timeouts, making it easier to send HTTP requests.1.1. FeaturesChrome browser automation using Selenium WebDriver.Built-in methods for form filling, scrolling, and waiting for elements.Anti-bot detection measuresPass selenium headers/cookies to requests libraryBuilt-in requests session with retries and timeouts.Ability to use Chrome user data for browser automation.RAM optimization for browser options.IntegratesHeliumfor easier automation2. Getting Started2.1. Installation2.1.1. ProductionInstall with flitpipinstallflit
flitinstall--depsproductionAlternatively, you can use pippipinstallak_selenium2.1.2. DevelopmentInstall with flitflitinstall--pth-file3. Usagefromak_seleniumimportChrome,By,Keyschrome=Chrome(headless=True)# Create a new Chrome browser instancedriver=chrome.driver#Get Chromedriverchrome.get("https://example.com")# Navigate to a webpage#Wait for element to loadlocator=(By.TAG_NAME,"h1")chrome.wait_for_locator(locator)s=chrome.session# Pass selenium session to requestss.get("https://www.iana.org/domains/reserved")# Get a website# Get a list of websites## Will randomize requests to not trigger bot detections.bulk_get(["https://www.iana.org/domains/reserved","https://www.example.com"])Integrated withHeliumto make it easier to set up automation.Helium methods and functions can be used as intended in theoriginal documentationExample:importheliumhelium.wait_until(helium.Button('Download').exists)Alternatively, helium methods and classes have been collected into two classesElementandActionfor convinienceElementexposes the following classes:Alert,Button,CheckBox,ComboBox,Image,Link,ListItem,RadioButton,Text,TextFieldand the methodfind_allActionexposes the following methods:highlight,wait_until,refresh,attach_file,drag_file,combobox_select,hover,write.Actionalso incorporates aMousesub-class that collect mouse-related methods.Example:fromak_seleniumimportElement,Action,Keysimportheliumchrome.get('https://google.com')#Go to websiteAction.write('helium selenium github')#Enter text into text fieldhelium.press(Keys.ENTER)#Press EnterAction.Mouse.click('mherrmann/helium')#Clickchrome.get('https://github.com/login')#Goto githubAction.write('username',into='Username')#Enter Username into Username fieldAction.write('password',into='Password')#Enter Password into Password fieldAction.Mouse.click('Sign in')#Click Sign-inAction.Mouse.scroll(direction='down',num_pixels=100)#Scroll down 100pxhelium.kill_browser()#Close the browser3.1. Additional Options# Selenium Overrides## Overide default useragentchrome.USERAGENT='Mozilla/5.0 (Windows NT 10.0; Win64; x64)\AppleWebKit/537.36 (KHTML, like Gecko)\Chrome/83.0.4103.53 Safari/537.36'## Override implicit and max wait times for seleniumchrome.IMPLICITLY_WAIT_TIME=3#secondschrome.MAX_WAIT_TIME=5#seconds# Requests.Session Overrides.MIN_REQUEST_GAP=0.9#seconds between requests4. RoadmapAdd beautifulsoup integrationProxy5. LicenseSee LICENSE for more information.6. ContactArun Kishore -@rpakishoreProject Link:https://github.com/rpakishore/ak_selenium7. AcknowledgementsAwesome README TemplateShields.ioHelium