|
@@ -55,41 +55,33 @@ class JixiangxingfuRecommend:
|
|
def start_wechat(cls, log_type, crawler, env):
|
|
def start_wechat(cls, log_type, crawler, env):
|
|
try:
|
|
try:
|
|
if env == "dev":
|
|
if env == "dev":
|
|
- chromedriverExecutable = '/Users/wangkun/Downloads/chromedriver/chromedriver_v107/chromedriver'
|
|
|
|
- # chromedriverExecutable = '/Users/tzld/Downloads/chromedriver_v111/chromedriver' # 本地
|
|
|
|
-
|
|
|
|
- # chromedriverExecutable = 'C:\\chromedriver\\chromedriver.exe' # 阿里云 Windows
|
|
|
|
|
|
+ chromedriverExecutable = "/Users/piaoquan/Downloads/chromedriver"
|
|
else:
|
|
else:
|
|
- chromedriverExecutable = '/Users/piaoquan/Downloads/chromedriver' # Mac 爬虫机器
|
|
|
|
- # chromedriverExecutable = '/Users/tzld/Downloads/chromedriver_v111/chromedriver' # 本地
|
|
|
|
-
|
|
|
|
- # chromedriverExecutable = 'C:\\chromedriver\\chromedriver.exe' # 阿里云 Windows
|
|
|
|
|
|
+ chromedriverExecutable = "/Users/piaoquan/Downloads/chromedriver"
|
|
|
|
|
|
- Common.logger(log_type, crawler).info('启动微信')
|
|
|
|
|
|
+ Common.logger(log_type, crawler).info("启动微信")
|
|
|
|
+ # Common.logging(self.log_type, self.crawler, self.env, '启动微信')
|
|
|
|
+ # 微信的配置文件
|
|
caps = {
|
|
caps = {
|
|
- "platformName": "Android", # 手机操作系统 Android / iOS
|
|
|
|
- "deviceName": "a0a65126", # 连接的设备名(模拟器或真机),安卓可以随便写
|
|
|
|
- # "udid": "emulator-5554", # 指定 adb devices 中的哪一台设备
|
|
|
|
- "platforVersion": "11", # 手机对应的系统版本
|
|
|
|
- "appPackage": "com.tencent.mm", # 被测APP的包名,乐活圈 Android
|
|
|
|
- "appActivity": ".ui.LauncherUI", # 启动的Activity名
|
|
|
|
- "autoGrantPermissions": "true", # 让 appium 自动授权 base 权限,
|
|
|
|
- # 如果 noReset 为 True,则该条不生效(该参数为 Android 独有),对应的值为 True 或 False
|
|
|
|
- "unicodekeyboard": True, # 使用自带输入法,输入中文时填True
|
|
|
|
- "resetkeyboard": True, # 执行完程序恢复原来输入法
|
|
|
|
- "noReset": True, # 不重置APP
|
|
|
|
- "printPageSourceOnFailure": True, # 找不到元素时,appium log 会完整记录当前页面的 pagesource
|
|
|
|
- "newCommandTimeout": 6000, # 初始等待时间
|
|
|
|
- "automationName": "UiAutomator2", # 使用引擎,默认为 Appium,
|
|
|
|
- # 其中 Appium、UiAutomator2、Selendroid、Espresso 用于 Android,XCUITest 用于 iOS
|
|
|
|
|
|
+ "platformName": "Android",
|
|
|
|
+ "devicesName": "Android",
|
|
|
|
+ # "platformVersion": "11",
|
|
|
|
+ # "udid": "emulator-5554",
|
|
|
|
+ "appPackage": "com.tencent.mm",
|
|
|
|
+ "appActivity": ".ui.LauncherUI",
|
|
|
|
+ "autoGrantPermissions": "true",
|
|
|
|
+ "noReset": True,
|
|
|
|
+ "resetkeyboard": True,
|
|
|
|
+ "unicodekeyboard": True,
|
|
"showChromedriverLog": True,
|
|
"showChromedriverLog": True,
|
|
- 'enableWebviewDetailsCollection': True,
|
|
|
|
- 'setWebContentsDebuggingEnabled': True,
|
|
|
|
- 'recreateChromeDriverSessions': True,
|
|
|
|
- 'chromedriverExecutable': chromedriverExecutable,
|
|
|
|
|
|
+ "printPageSourceOnFailure": True,
|
|
|
|
+ "recreateChromeDriverSessions": True,
|
|
|
|
+ "enableWebviewDetailsCollection": True,
|
|
|
|
+ "setWebContentsDebuggingEnabled": True,
|
|
|
|
+ "newCommandTimeout": 6000,
|
|
|
|
+ "automationName": "UiAutomator2",
|
|
|
|
+ "chromedriverExecutable": chromedriverExecutable,
|
|
"chromeOptions": {"androidProcess": "com.tencent.mm:appbrand0"},
|
|
"chromeOptions": {"androidProcess": "com.tencent.mm:appbrand0"},
|
|
- # "chromeOptions": {"androidProcess": "com.tencent.mm:tools"},
|
|
|
|
- 'browserName': ''
|
|
|
|
}
|
|
}
|
|
try:
|
|
try:
|
|
driver = webdriver.Remote("http://localhost:4723/wd/hub", caps)
|
|
driver = webdriver.Remote("http://localhost:4723/wd/hub", caps)
|
|
@@ -128,7 +120,7 @@ class JixiangxingfuRecommend:
|
|
)
|
|
)
|
|
size = driver.get_window_size()
|
|
size = driver.get_window_size()
|
|
driver.swipe(int(size['width'] * 0.5), int(size['height'] * 0.8),
|
|
driver.swipe(int(size['width'] * 0.5), int(size['height'] * 0.8),
|
|
- int(size['width'] * 0.5), int(size['height'] * 0.2), 200)
|
|
|
|
|
|
+ int(size['width'] * 0.5), int(size['height'] * 0.2), 100)
|
|
# driver.find_element(By.ID, 'com.android.systemui:id/dismiss_view').click()
|
|
# driver.find_element(By.ID, 'com.android.systemui:id/dismiss_view').click()
|
|
else:
|
|
else:
|
|
pass
|
|
pass
|
|
@@ -144,11 +136,11 @@ class JixiangxingfuRecommend:
|
|
)
|
|
)
|
|
size = driver.get_window_size()
|
|
size = driver.get_window_size()
|
|
driver.swipe(int(size['width'] * 0.5), int(size['height'] * 0.2), int(size['width'] * 0.5),
|
|
driver.swipe(int(size['width'] * 0.5), int(size['height'] * 0.2), int(size['width'] * 0.5),
|
|
- int(size['height'] * 0.8), 200)
|
|
|
|
|
|
+ int(size['height'] * 0.8), 100)
|
|
# 打开小程序"祝福大家好才是真好"
|
|
# 打开小程序"祝福大家好才是真好"
|
|
time.sleep(5)
|
|
time.sleep(5)
|
|
Common.logger(log_type, crawler).info('打开小程序"祝福每天好运来相伴"')
|
|
Common.logger(log_type, crawler).info('打开小程序"祝福每天好运来相伴"')
|
|
- driver.find_elements(By.XPATH, '//*[@text="祝福每天好运来相伴"]')[-1].click()
|
|
|
|
|
|
+ driver.find_elements(By.XPATH, '//*[@text="祝福大家发财幸福噢"]')[-1].click()
|
|
AliyunLogger.logging(
|
|
AliyunLogger.logging(
|
|
code="1000",
|
|
code="1000",
|
|
platform=JixiangxingfuRecommend.platform,
|
|
platform=JixiangxingfuRecommend.platform,
|