Package: bas-remote-python
bas-remote-pythonbas-remote-python- Python library, which allows you toautomate Google Chrome browser.In order to make it possible, BrowserAutomationStudio application is used.bas-remote-pythonallows you to call and control execution of functions created in BAS. Consider following example, you have a BAS function, which executes specified Google search query and returns result as a list of urls. Using this library, you can call that function in any Python application and obtain result. You can distribute applications written withbas-remote-pythonlibrary as well.BrowserAutomationStudioBAS- is application that allows you to automate any activities in Google Chrome browser with a help of visual programming and without knowing of any programming language. You can think of it as IDE created especially for browser automation:Check following link for more info:https://bablosoft.com/shop/BrowserAutomationStudioInstallationpip install bas-remote-pythonQuick exampleFollowing code will search forcatsquery in Google and output result into console. You can just copy paste this code and run it.importasynciofrombas_remoteimportBasRemoteClientfrombas_remoteimportOptionsasyncdefmain():# Set script name, and optionally auth details (login, password).options=Options(script_name='TestRemoteControl')# Create client.script_client=BasRemoteClient(options)# Start application, this may take some time.awaitscript_client.start()# Set parameters for function.script_params={'Query':'cats'}# Run function and wait for result.# Following function will return list of strings.result=awaitscript_client.run_function('GoogleSearch',# or 'YourFunctionName'script_params)# Iterate and output results.forlinkinresult:print(link)awaitscript_client.close()if__name__=='__main__':asyncio.run(main())Checkoutwikifor more examples.Running custom codePrevious example usedTestRemoteControlproject andGoogleSearchfunction defined in it.
In most cases you want to use your own projects and functions. In order to do it:Install BAS. Download using followinglink.IMPORTANTYou need to be a premium user in order to create project with custom functions.Startrecord modeand create new function by usingfunction manager. BAS functions works like functions in any other languages. They can be called with parameters and can return value as a result. Functions help to incapsulate and reuse your code.Implement it. On following step you need to implement required functionality. Place code into the function that you have created on previous step. They will be called from Python code later. Function parameters will be sent from Python to BAS, while return value will be sent from BAS to Python. Working with BAS is out of scope of this article, checkBAS wikifor more info.Compile it and give it a name. Check thisarticlemore more instruction for compilation.Finally,allow remote function executionflag for script must be set. You can do that on followingpage. Seescreenshotfor more details.After project with function is prepared, you can use it from Python.
In order to do that, change script and function name in example above.How it worksFollowing diagram will explain project architecture:Running custom codesection explains how to prepare your project and upload it into the cloud. Portable BAS instance is downloaded and started automatically, it is also closed automatically whenBasRemoteClientgets closed. Folder, where portable BAS instance is located by default isdatafolder relative to executable. It can be customized by usingoptions.working_dirsetting.Project exampleYou can useTestRemoteControlproject in order to testbas-remote-pythonlibrary. It is already uploaded into the cloud and can be used without authentication. List of available functions:Add(X,Y)- adds two numbers and return their sum.SetProxy(Proxy,IsSocks5)- sets proxy for current thread.Proxyparam is proxy string,IsSocks5is string("true", "false") value indicates if proxy type is socks5. No return value.CheckIp()- returns remote IP of current thread. Uses ip.bablosoft.com service to test. Can be combined withSetProxyfunction.GoogleSearch(Query)- performs Google query, returns result as a list of urls.Project source code can be downloadedhereLicensebas-remote-pythonhas MIT license.You can distribute applications usingbas-remote-pythonlibrary, including commercial, to user, who don't have BAS premium subscription without any fees.In order to create project with custom functions you need to have a BAS premium subscription.In other words, only developers must have BAS premium subscription, not users.