1

I am wondering if it is possible to pull the innerHTML of a web page once it is loaded via ADB command line only.

I want to check my public IP address of my android device to verify the Proxy is active before running additional commands/services. I plan to validate the known Proxy using https://api.ipify.org

I can run the following command: adb shell am start -a android.intent.action.VIEW -d https://api.ipify.org Only problem is i have no way of grabbing the result and relaying it back via command line. I also want to avoid opening a web page on the device and have this query be done in the background.

Just to add that I am rooted which may help with the solution.

I have done a lot of research and came across this tool: https://www.cyberciti.biz/faq/unix-linux-get-the-contents-of-a-webpage-in-a-terminal but have no idea how to get this to work or even if this is the way to go.

I know how to do this using VB with the post method using a WinHttp request, but when it comes to android/linux I am completely lost!

Thanks in advance

Kind regards, Maddis :)

Lino
  • 5,084
  • 3
  • 21
  • 39
Mad Dire
  • 33
  • 5
  • 1
    Not like that. What you're doing is telling it to run whatever your default http handler (default web browser) is. The am program doesn't know what html is. If you really want to do this, I'd suggest installing an ARM version of wget or curl on your phone and running that. – Gabe Sechan Feb 11 '22 at 04:18
  • Ok thanks, will try this – Mad Dire Feb 11 '22 at 13:48

1 Answers1

1

Using am start to execute something you want to get the response of is a bad idea because am start works asynchronously and thus can not give you any direct response.

As it is your phone only I recommend to install a a Linux command-line tool like curl or wget to /data/local/tmp or /data/local depending on your Android version. A simple wget version is usually included in busybox so there should be a number of precompiled binaries available you can simply push to thed evice, copy to /data/local/tmp or /data/local, make it executable via chmod and then use to request your public IP using the mentioned API.

Robert
  • 39,162
  • 17
  • 99
  • 152