derrickx před 1 rokem
rodič
revize
5478537b30

+ 1 - 1
.idea/misc.xml

@@ -3,5 +3,5 @@
   <component name="Black">
     <option name="sdkName" value="Python 3.12" />
   </component>
-  <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.11" project-jdk-type="Python SDK" />
+  <component name="ProjectRootManager" version="2" project-jdk-name="awesome-python" project-jdk-type="Python SDK" />
 </project>

binární
instagram/screenshots/1714313789.422389.png


binární
instagram/screenshots/1714314190.1217852.png


binární
instagram/screenshots/1714314224.692939.png


binární
instagram/screenshots/1714314590.5102878.png


binární
instagram/screenshots/1714314660.021794.png


binární
instagram/screenshots/1714314880.858568.png


binární
instagram/screenshots/1714314942.883649.png


binární
instagram/screenshots/1714315284.970228.png


binární
instagram/screenshots/1714315370.4075751.png


binární
instagram/screenshots/1714315449.7598238.png


binární
instagram/screenshots/1714315502.043844.png


binární
instagram/screenshots/1714315566.244193.png


binární
instagram/screenshots/1714315630.654495.png


binární
instagram/screenshots/1714315682.259264.png


+ 41 - 3
instagram/spider_poc.py

@@ -3,11 +3,11 @@ import sys
 import time
 
 import uiautomator2 as u2
+from cnocr import CnOcr
 
 
 def spider_poc(serial):
     d = u2.connect(serial)
-    d.uiautomator.start()
     d.screen_on()
     d.unlock()
     d.debug = False
@@ -17,11 +17,49 @@ def spider_poc(serial):
 
     time.sleep(3)
 
+    """滑动一屏幕"""
+    # d.swipe_ext('up', scale=1)
+    # time.sleep(1)
+
     root_dir = os.path.dirname(sys.argv[0])
-    screenshot_dir = os.path.join(root_dir, "screenshots")
+    screenshot_name = f'screenshots/{time.time()}.png'
+    screenshot_dir = os.path.join(root_dir, screenshot_name)
     d.screenshot().save(screenshot_dir)
 
+    ocr = CnOcr()
+    res = ocr.ocr(screenshot_dir)
+    # print(res)
+
+    # 找到包含“你的快拍”的元素
+    target_text = '你的快拍'
+    i = 0
+    for i, item in enumerate(res):
+        if target_text in item['text']:
+            break
+
+    if i < len(res) - 1:
+        next_text = res[i + 1]['text']
+        # print(f"“{target_text}”后的文字是:“{next_text}”")
+        print(f"昵称:{next_text}")
+    else:
+        print("未找到昵称")
+
+    """点赞"""
+    # d.xpath('//*[@resource-id="com.instagram.android:id/row_feed_button_like"]').click(timeout=3)
+    d.double_click(0.51, 0.493)
+    time.sleep(3)
+
+    """搜索"""
+    d.xpath('//*[@resource-id="com.instagram.android:id/search_tab"]/android.widget.ImageView[1]').click(timeout=3)
+    time.sleep(1)
+    d.xpath('//*[@resource-id="com.instagram.android:id/action_bar_search_edit_text"]').click(timeout=3)
+    d(focused=True).set_text('电子元器件')
+    time.sleep(3)
+    d.xpath('//*[@resource-id="com.instagram.android:id/row_search_profile_image"]').click(timeout=3)
+
+    """点击账户"""
+    d.xpath('//*[@text="帐户"]').click()
+
 
 if __name__ == '__main__':
     spider_poc("5D7HSG5XXCKVBI85")
-