Last time we have mounted python files to the virtual machine, this time we will mainly set the virtual machine through the Docker container mode.






run

  • Python code run > start a CRT session
docker run -it -v /root/docker:/root --name python zhugeaming/python3-appiumCopy the code




  • The operation of the mitmdump
Start a CRT session, which can be distinguished by the same name as session
docker run --rm -it -v /root/docker:/root/ -p 8889:8889 --name mitmdump zhugeaming/python3-appium mitmdump -p 8889 -s /root/decode_data.pyCopy the code












  • Run appium > start a CRT session, which can be distinguished by using the same name as session. Here we need to note that we need to start three apps because we monitor the code of three apps. Before, I demonstrated whether to start the client service of multiple Appium, in this case, by container means to start three containers.
docker run --privileged -d -p 4723:4723 --name appium_douyin appium/appium
docker run --privileged -d -p 4725:4723 --name appium_kuaishou appium/appium
docker run --privileged -d -p 4727:4723 --name appium_jrtt appium/appiumCopy the code




  • 1. Set the network bridge mode



2. Install the mitmdump certificate inside the container

Mitmproxy was introduced before the certificate installation.




3. After setting up one, you can copy the functions of the emulator

Picture uploaded



4. Set up the local ADB devices and convert them to TCP

Adb Connect 127.0.0.1:62001 ADB connect 127.0.0.1:62025 ADB connect 127.0.0.1:62026 ADB Devices ADB-s127.0.0.1:62001 5555 adb tcpip-s127.0.0.1:62025 5555 adb tcpip-sTcpip 127.0.0.1-62026, 5555Copy the code


Picture uploaded



  • Container appium setup connection > 192.168.199.122 is The IP of the Python simulator – Tiktok > 192.168.199.117 is the IP of the Python simulator – Quickhand > 192.168.199.173 is the IP of the Python simulator – Today’s Headlines
docker exec -it appium_douyin adb connect 192.168.199.122:5555
docker exec -it appium_kuaishou adb connect 192.168.199.117:5555
docker exec -it appium_jrtt adb connect 192.168.199.173:5555

What if I write the IP incorrectly, what if I mount it incorrectly
Docker execit adb kill-server` ` ` `! [](https://upload-images.jianshu.io/upload_images/11223715-fb9572508a1eeafb.png? ImageMogr2 /auto-orient/strip% 7cimageView2/2 /w/1240) * Handle_appium_docker. ! [](https://upload-images.jianshu.io/upload_images/11223715-233b196366015f20.png? ImageMogr2 /auto-orient/strip% 7cimageview2/2 /w/1240) > [](https://upload-images.jianshu.io/upload_images/11223715-985aa964f84cb4f7.png? ImageMogr2 /auto-orient/strip% 7cImageView2/2 /w/1240) > [](https://upload-images.jianshu.io/upload_images/11223715-b134b601f5607bdd.png? ImageMogr2 /auto-orient/strip% 7CImageView2/2 /w/1240) * Handle_mongo.py python code changes! [](https://upload-images.jianshu.io/upload_images/11223715-ff494634f717b607.png? imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)#### these Settings can be basically captured our data> Execute the code directly in Python. ``` python python handle_appium_docker.pyCopy the code






Picture uploaded



Mongo’s data


Picture uploaded



PS: Computer configuration is relatively high I7 CPU, 16G memory, solid state hard disk, try to use the real machine, if it is a real machine 8G run is also very 666, enterprises or use real mobile phones to run. Here is a comprehensive combat, from the use of appium, the use of mobile terminal, the use of MITMDump, are integrated together. Encounter problems actually baidu and Google has a similar problem, many parts are reference: https://github.com/appium/appium-docker-android, ha ha the nation’s largest men dating site very awesome.

>> Original article, welcome to reprint. Reprint please specify: reprint from IT people story, thank you!

Python docker- build multitask app data capture system (ii) (35)