GithubHelp home page GithubHelp logo

bubdm / basremote.net Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cheshirecaat/basremote.net

0.0 0.0 0.0 1.93 MB

.NET library, which allows you to automate Google Chrome browser.

License: MIT License

C# 100.00%

basremote.net's Introduction

BASRemote.NET

NuGet version Build status GitHub issues License: MIT

BASRemote - .NET library, which allows you to automate Google Chrome browser. In order to make it possible, BrowserAutomationStudio application is used. BASRemote allows 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 C# application and obtain result. You can distribute applications written with BASRemote library as well.

BrowserAutomationStudio

BAS - 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/BrowserAutomationStudio

Installation

Install package via NuGet:

> Install-Package BASRemote

Build from source

  1. Clone this repo to your PC.
  2. Compile source with VS2019 or Rider.
  3. Add reference to BASRemote.dll to your project.

Quick start

Following code will search for cats query in Google and output result into console. You can just copy paste this code and run it.

//Set script name, and optionally auth details (login, password) 
var ScriptOptions = new BASRemote.Options
{
	ScriptName = "TestRemoteControl" /* or "YourScriptName" */
};

//Create client
using (var ScriptClient = new BASRemote.BasRemoteClient(ScriptOptions))
{
	//Start application, this may take some time
	await ScriptClient.Start();

	//Set parameters for function
	var ScriptParams = new BASRemote.Objects.Params
	{
    		["Query"] = "cats"
	};

	//Run function and wait for result
	//Following function will return list of strings
	var Result = await ScriptClient.RunFunction(
		"GoogleSearch", /* or "YourFunctionName" */
		ScriptParams
	).GetTask<string[]>();

	//Iterate and output results
	foreach(var Link in Result)
	{
    		Console.WriteLine(Link);
	}

}

Checkout wiki for more examples.

Running custom code

Previous example used TestRemoteControl project and GoogleSearch function defined in it. In most cases you want to use your own projects and functions. In order to do it:

  • Install BAS. Download using following link. IMPORTANT You need to be a premium user in order to create project with custom functions.
  • Start record mode and create new function by using function 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 C# code later. Function parameters will be sent from C# to BAS, while return value will be sent from BAS to C#. Working with BAS is out of scope of this article, check BAS wiki for more info.
  • Compile it and give it a name. Check this article more more instruction for compilation.
  • Finally, allow remote function execution flag for script must be set. You can do that on following page. See screenshot for more details.

After project with function is prepared, you can use it from C#. In order to do that, change script and function name in example above.

How it works

Following diagram will explain project architecture:

Running custom code section 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 when BASRemote gets disposed. Folder, where portable BAS instance is located by default is data folder relative to executable. It can be customized by using BASRemote.Options.WorkingDirectory setting.

Project example

You can use TestRemoteControl project in order to test BASRemote.NET library. It is already uploaded into the cloud and can be used without authentication. List of available functions:

  • Add(X,Y) - adds to numbers return their sum.
  • SetProxy(Proxy,IsSocks5) - sets proxy for current thread. Proxy param is proxy string, IsSocks5 is 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 with SetProxy function.
  • GoogleSearch(Query) - performs Google query, returns result as a list of urls.

Project source code can be downloaded here

Dependencies

This library has dependencies on several excellent libraries:

Newtonsoft.Json

WebSocketSharp

License

BASRemote.NET has MIT license.

You can distribute applications using BASRemote.NET library, 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.

basremote.net's People

Contributors

bablosoft avatar cheshirecaat avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.