Read APK file from URL in Python 2.7

1.7k Views Asked by At

I am working on a Python Script which reads the APK file which is stored in a folder on the same server on which the Script is running.

here is the code I am using:

apk_path = "/var/fibo-dev/public/uploads/apks/TvBox-release-signed-latest.apk"

apkf = APK(apk_path)
is_valid = apkf.is_valid_APK()
package  = apkf.get_package()
version  = apkf.androidversion
version  = version['Name']

APK Parsing Package:
https://github.com/androguard/androguard

The Script reads the content of the APK like it's version, package name etc and then store the info in a csv.

As you can see the APK I am reading is stored on the same server on which the script is placed.

But now the thing is I want to read the APK which is placed on a different server. i.e. https://fibo.network/uploads/apks/18243602447plus_v4.3.4.apk

and when I try to do the same thing for the given url it doesn't work.

for example:

url = urllib2.urlopen("https://fibo.network/uploads/apks/18243602447plus_v4.3.4.apk")
apkf = APK(url.read())

It gives the error:

file() argument 1 must be encoded string without null bytes, not str

I tried to use a different methods like:

urlopen , requests.get

and more But none of those worked for me.

So I am requesting you to help me to get this thing worked out.

Thanks.

0

There are 0 best solutions below