preface

Before I wrote an article about how to learn a new skill: [It’s all dry stuff], no theory, it’s all real. In the fifth point, I mentioned using script to play exploration. Yesterday, I spent an hour to implement this function.

Github: Probe robot, automatically according to different girl/man appearance level, age and other types, like, ignore, welcome everyone star

Let’s take a look at the implementation first

Today’s topic is: Use script + WebDriverAgent to automate any mobile App you want.

Explore the realization principle of “robot”

  1. The device enables WebDriverAgent

  2. Using USBMUxD (iTunes communicates with iPhone using USBMUx, usBMUxD provides USB-TCP conversion service), the iProxy inside converts the device port to the local port

    > brew install usbmuxd
    > iproxy 8100 8100  Map port 8100 on the device to port 8100 on the PC
    Copy the code
  3. Use scripts to manipulate mobile apps, such as Python (for other languages, you can find them on package management websites, such as Node).

    import wda  # https://pypi.org/project/facebook-wda/
    wdaClient = wda.Client()
    tantan_session = wdaClient.session('com.yaymedialabs.putong')  The Bundle ID of the probe is in parentheses. How to obtain the Bundle ID will be discussed later
    wdaClient.screenshot('iphone_screen.png')  # Capture the phone screen and save it as iphone_screen.png
    img_face = iphone_screen.crop((34.215.1208.1560))  # Intercept Plus according to the coordinate points to explore the photos inside
    Copy the code
  4. The above photos have been obtained from Tantan. At this time, we can call the third-party API to analyze the data of the photos, for example, Tencent’S AI API

  5. Based on the results obtained in step 4, use the tantan_session command and click the corresponding button

    tantan_session.tap(780.2028)  # Plus explores the coordinates of the like button
    Copy the code

expand

  1. facebook-wdaFor more details, seeThe document
  2. Tantan-bot only realizes the simplest functions, but in fact it is easy to add functions. For example, if the face cannot be recognized in the first screenshot, the script can click the photo to slide in and judge whether to like or ignore the face after detecting it (not bad for every girl 😁).
  3. Python’s image processing is handy. For example, you can write a script to monitor whether your girlfriend has sent you new messages on wechat in real time. My idea: every 5 seconds OCR recognizes the chat window, and then takes the last piece of data that OCR recognizes (not your own sent), and adoptsSimhashAlgorithm comparing with the last time is the same, if the acquaintance degree is not high, proved to be a new message, call the tripartite bot API (of course, you can pick out your own chat data classification algorithm with a class, when the new message comes in your language garage to find the most suitable for your girlfriend back, looks not like a robot 😀), So the girl friend chatted happily with intelligent robot one night, moved oneself to cry 🤣
  4. This is used to play games have practice, such as: jump
  5. In this way can also be very convenient to achieve the automatic snatching function, save to break the agreement, a few words of code. 😆
  6. With a slight modification, momo Robot, Tiktok Robot, etc., can be implemented in 70 lines of code.

supplement

  1. The Bundle ID for: https://offcornerdev.com/bundleid.html
  2. OCR recognition: Baidu API, Google Tesseract

The last

Next time we meet, maybe I will have realized the above things oh, to wave attention, star, ha ha!

Simultaneous publication of articles: blog