How to Crawl Android APK from apkpure
Published: 2022-11-11 08:10:18

The article will guide you to quickly crawl and download Android applications from the [apkpure](https://m.apkpure.com/).

## The factors important for that are
1. Browser (such as Chrome)
2. NodeJS ([install](https://nodejs.org/en/download/))

## Analysis web page

Select an application from the [home page](https://m.apkpure.com/) to enter the download page. For example, I select [this page](https://m.apkpure.com/fifa-soccer/com.ea.gp.fifamobile/download?from=details) and use F12 shortcut to open the console. Select the download button to see the download link of the application.
![download url](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/426e1d99gho9ghoubxc4.png)


Access this [link](https://d.apkpure.com/b/APK/com.ea.gp.fifamobile?version=latest) to download the latest version of the application.

If you want to download other packages, you only need to download and modify the package name in the link:
`https://d.apkpure.com/b/APK/{PACKAGE_NAME}?version=latest`
If you want to download other versions of packages, you can specify the version code:
`https://d.apkpure.com/b/APK/{PACKAGE_NAME}?versionCode={VERSION_CODE}`

Other information about the package can be obtained through another page, such as version number, developer, release date, etc.
![apk info](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vlc0nlopzwb3ovhieavw.png)


We can also get all the historical versions of the application through the historical version page. It should be noted here that the file types are divided into XAPK and APK. XAPK requires a special installer to install on the device, so we only need APK files.
![other versions](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rlthsako8188nu9cedva.png)



## Scraping APK through crawlers

### 1. Downloading APK

We already know the assembly rules of the download link. We only need to download it through the package name. Enter the assembled download link (e. g. https://d.apkpure.com/b/APK/com.ea.gp.fifamobile?version=latest) into the browser to download it directly.

However, if you want to download it outside the browser, you will be blocked by the Cloudflare. In order to avoid being blocked, we can use the js package puppeteer to simulate the browser's access behavior and download.


### 2. Scraping APK Details

In order to prevent requests from being intercepted by Cloudflare, scraping APK details can also be implemented using puppeteer.

For example, after opening the apkpure application details page, you can obtain the application details through the following program.
![code](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cyhkbut1otidyu3yd5bt.png)



## Obtained through the js package provided by the author

If you think it is very troublesome to realize this ability, you can choose js package [apkpure-crawler](https://www.npmjs.com/package/apkpure-crawler) provided by the author. The usage is also very simple:

If you already have a NodeJS and npm, you can simply install the program to your computer through the following command
```
npm install -g apkpure-crawler
```

This tool can provide the following abilities:
```
# get package download url with package name
apkcrawl get com.ea.gp.fifamobile

# download package with package name
apkcrawl down com.ea.gp.fifamobile

# crawler package info with package name
apkcrawl crawler com.ea.gp.fifamobile
```