浏览量:13次
import time
import random
import pyautogui
def main(args):
Inputkeywords = args
XHSfind = xbot.web.create("https:/**ww.xiaohongsh*.c*m/explore","chrome",load_timeout = 30)
#XHSfind = xbot.web.get_active(mode='chrome')
Delaytime = random.uniform(5, 10)
time.sleep(Delaytime)
Inputbox = XHSfind.find_by_xpath('//input[@id="search-input"]')
Inputbox.input(Inputkeywords,send_key_delay=800,delay_after=3)
#Inputbox.input("合肥市公司",send_key_delay=800,delay_after=3)
Searchbutton = XHSfind.find_by_xpath('//div[@class="search-icon"]')
Searchbutton.click(delay_after = 3,move_mouse = True)
Delaytime = random.uniform(5, 10)
time.sleep(Delaytime)
XHSbrowser = xbot.web.get_active(mode='chrome')
XHSbrowser.find_by_xpath('//span[text()="筛选"]').hover(simulative=True,delay_after=3)
Delaytime = random.uniform(4, 8)
Noseen = XHSbrowser.find_by_xpath('//span[text()="未看过"]')
Noseen.click(delay_after = 2,move_mouse = True)
Up_to_date = XHSbrowser.find_by_xpath('//span[text()="*新"]')
Up_to_date.click(delay_after = 2,move_mouse = True)
Selected = XHSbrowser.find_by_xpath('//span[text()="已筛选"]')
Selected.click(delay_after = 3,move_mouse = True)
print("【前期准备】运行无异常")
print("【for循环评论】运行开始")
def scroll_down_pixels(pixels: int):
Delaytime = random.uniform(2, 5)
time.sleep(Delaytime)
pyautogui.scroll(-pixels)
return None
话术1 = "[点赞R][点赞R]"
话术2 = "[抱拳R]"
话术3 = "[抱拳R][抱拳R][点赞R]"
话术4 = "[抱拳R][点赞R]"
话术5 = "[点赞R][抱拳R][抱拳R][抱拳R][点赞R]"
随机话术 = [话术1,话术2,话术3,话术4,话术5]
for i in range(88):
留言话术 = random.choice(随机话术)
try:
Creativework = XHSbrowser.find_by_xpath(f'//section[@data-index="{i}"]//a[contains(@class, "cover")]')
Creativework.click(delay_after = 3,move_mouse = True)
Delaytime = random.uniform(2, 5)
time.sleep(Delaytime)
User = xbot.web.get_active(mode="chrome")
Messageinputbox = User.find_by_xpath('//span[text()="说点什么..."]')
Messageinputbox.input(留言话术,simulative=True,send_key_delay=800,delay_after=3,contains_hotkey=True)
xbot.win32.send_keys(keys='{enter}')
Delaytime = random.uniform(2, 5)
time.sleep(Delaytime)
xbot.win32.send_keys(keys='{Esc}')
print(f"第 {i+1} 次循环,评论话术为:{留言话术}")
except Exception as e:
Delaytime = random.uniform(2, 5)
time.sleep(Delaytime)
scroll_down_pixels(200)
continue
xbot.web.close_all('chrome')
pass
#仅供学习交流,严禁商用。 技术支持:若愚网络 汪华贝 18110488611(同V)