Controlling the phone with python

shzofren

Registered Member
Joined
Jun 9, 2020
Messages
55
Reaction score
4
I have a bot program for instagram written in python selenium. I want to connect my android phone with usb to the program and enable the program to turn the mobile data of the phone on and off. so it will be like a mobile proxy. how can I do that ?
 
Just use os.system and adb.
Here is some code that I used to enable data:
Code:
import os

os.system("adb shell svc wifi disable & adb shell svc data enable")
For changing ip:
Code:
os.system("adb shell settings put global airplane_mode_on 1 & adb shell am broadcast -a android.intent.action.AIRPLANE_MODE")

For using this IP with your script, I think you could do a usb tether and connect that way, and change ip then activate the tether again.
Found this on USB tethering via adb: https://stackoverflow.com/questions...android-device-using-adb-through-the-terminal
Just integrate this in between your script and it should work well.
Also UiAutomator for screen control: https://pypi.org/project/uiautomator/

There are paid Instagram account creators available, and accounts aren't that expensive so do consider those options as well.

Let me know if you have any questions!
 
Back
Top