from appium import webdriver
import time
from selenium.webdriver.support import expected_conditions as EC
from appium.webdriver.common.touch_action import TouchAction
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
desired_caps={
"platformName": "Android",
"deviceName": "a",
"appPackage": "com.tencent.mm",
"appActivity": "com.tencent.mm.ui.LauncherUI",
'noReset':True
}
url = 'http://localhost:4723/wd/hub'
driver = webdriver.Remote(url,desired_capabilities=desired_caps)
driver.wait_activity('.ui.LauncherUI',timeout=10)
WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.XPATH, '//*[@text="通讯录"]'))
).click()
driver.find_element_by_xpath('//*[@text="公众号"]').click()
driver.wait_activity('.plugin.brandservice.ui.BrandServiceIndexUI',timeout=10)
while True:
try:
items = driver.find_elements_by_xpath('//*[@resource-id="com.tencent.mm:id/a2y"]')
for item in items:
item.click()
driver.wait_activity('.ui.chatting.ChattingUI',timeout=10)
driver.find_element_by_id('com.tencent.mm:id/jy').click()
driver.wait_activity('.plugin.profile.ui.ContactInfoUI',timeout=10)
# driver.find_element_by_id('com.tencent.mm:id/b0u').click()
TouchAction(driver).press(x=569, y=2000).move_to(x=390, y=792).release().perform()
driver.find_elements_by_xpath('//*[@resource-id="com.tencent.mm:id/b0r"]')[-1].click()
driver.wait_activity('.plugin.profile.ui.ContactInfoUI', timeout=10)
driver.back()
driver.back()
driver.back()
except Exception as e:
pass
time.sleep(1)
mitm代理中间人代码
import sys
sys.path.append('..')
sys.path.append('../..')
sys.path.append('../../..')
import re
import redis
from wechat.settings import QUEUES
QUEUE_CONF = QUEUES['tasks']
r = redis.Redis(**QUEUE_CONF)
class WeChatProxyHandler():
url = 'https://mp.weixin.qq.com/mp/profile_ext?action=home'
def response(self,flow):
if (flow.request.url.find(self.url))!=-1:
for line in flow.response.text.split('\n'):
line = line.strip()
if line.find('var msgList') != -1:
line = eval(re.sub('"', '"', line[len('var msgList = ') + 1:-2]))
urls = [item.get('app_msg_ext_info', {}).get('content_url') for item in line['list']]
urls = [re.sub('\\\/', '/', url) for url in urls if url]
r.lpush('wechat', *urls)
addons=[
WeChatProxyHandler()
]