- Published on
How to apply proxy in Browser Automation Studio
- Authors
- Name
- Gen9X
- X
- @gen9xdotcom
There are many automation tools to create social network accounts such as X, Facebook, TikTok... In order for the created account to not be banned or locked, the tools will need to use many different techniques so that social network systems do not recognize the account as coming from a single source.
Among those techniques, there is an extremely important factor: hiding the real IP address and how each social network account will access through a different IP address.
So how do the tools do that? The answer is to use a proxy.
In this article, I will not discuss the theory of proxies, types of proxies... but will focus on how to use proxies in Browser Automation Studio. Get your proxy ready and follow the instructions below to do it.
There are many ways to load proxies into Browser Automation Studio (BAS), I often use the method of loading from the input file. This will make it easier to change proxies from one provider to another, from one proxy type to another, without having to edit scripts.
1. Create a new project in BAS
Open BAS and create a new BAS project, save it to any location you want on your computer. Make sure you are opening the correct project by looking at the path displayed in the Current project
section to see if it is correct.
2. Create a new resource.
As mentioned, we will create an input file with a list of proxies and then read it from the file. To do this, we need to do the two steps below.
2.1. Create a proxies.txt file
Usually I will create the proxies file in the same directory as the project's xml file. Its structure will be as follows:
├── apply-proxies-project
│ ├── proxy.xml
│ ├── proxies.txt
So what will the content inside the proxies.txt
file be?
Currently, BAS supports 4 types of proxies:
- http
- https
- socks
- socks5
And BAS supports the following proxy string format:
- ip:port
- username:password@ip:port
- socks5://ip:port
- socks:ip:port:username:password
- http:username:password:ip:port
In fact, when using BAS, we will run many parallel threads, each thread will use a different proxy. Therefore, the proxies.txt
file will also contain many proxies, each proxy is 1 line.
For example, if you have 5 proxies, the proxies.txt
file will have the following content:
username1:password1@ip1:port1
username2:password2@ip2:port2
username3:password3@ip3:port3
username4:password4@ip4:port4
username5:password5@ip5:port5
Or in some cases where you have authorized IP access, you will not need to provide username and password anymore, then the content will be simpler:
ip1:port1
ip2:port2
ip3:port3
ip4:port4
ip5:port5
2.2. Create a resource
First, click on the Create New Resource
button
Next, name this resource, remember to name it so that you can easily understand that it is a proxy. As for the description, it is up to you, fill in anything. Click Next
after filling in all the information.
Then select LinesFromFile
. It means that it will read each line in the proxies.txt
file and use that line as the value.
Next, select Only read
because normally with a proxy, it will only read it and use it, not edit or delete it.
Next, select Use each line several times
. This means that the script will use a proxy multiple times and will only stop the script when the number of successful or failed attempts reaches the configured number.
You can double-click on that resource to view information and edit the number of successful or failed uses as I mentioned above. The default value is 10 successful or 10 failed uses, then that proxy will not be used anymore. I usually set it to a very large number, for example 100000
3. Use the proxy
Now click on the Record
button to start editing the script and using the proxy right away.
A popup will then appear for you to provide input information for the resources, as in this case you need to tell the script which path to read the proxies.txt
file. To select the file path, click on the button I circled in red as shown below.
Once you have selected everything, you can click OK
to go to the script editing section.
Since your script will have many functions, it is best to create different functions to handle them. This helps your script to be neat and easy to develop as well as fix errors if any.
Now I will create a new function called SetupProxy
to configure the proxy. To create a new function, follow these steps:
- Click on the area below as shown in the red square.
Click on the red circle button with the plus sign in the middle
Enter the function name
SetupProxy
and then clickSave changes
So the new function has been created, now we will process the proxy logic.
On the list of functions provided by BAS, enter proxy search and select the function as I circled in red.
Next, configure as follows:
Proxy String: Click and select
Load from file, user input, database
, then selectPROXY
. This is the proxy value read from theproxies.txt
file.Proxy Type: choose the correct type, usually it will be http or socks5.
Proxy login, proxy password: If the
proxies.txt
file has provided username and password, leave it blank.
In some cases, proxy service providers have actively changed IP via API, then you can use http client to call api to change or get new proxy/api information and use. In this content, I will search for a service provider and demo how to do it in the next article.
So the proxy configuration is done, next we will call the SetupProxy
function inside the Main
function using the Call Function
function in BAS.
Finally, you can load the browser and try to access the website What is My IP Address to check for sure if the proxy is working or not.
In some cases, you will see the script display an error that the proxy cannot be used or cannot get the IP address. This means that the proxy has expired, the information is incorrect, the access capacity has run out.... Then you should check the proxy again or contact the proxy provider to investigate the problem.
After successfully using the proxy, you can continue to perform other settings such as browser fingerprinting, script automation....
Wish you success with the automation script, if it is difficult or impossible to do, just hire me, I will build it for you.