baidu-reporter/tests/test_evidence.py
2025-03-30 16:04:34 +08:00

48 lines
1.2 KiB
Python

from DrissionPage import ChromiumOptions
from DrissionPage import Chromium
chrome_opts = ChromiumOptions()
chrome_opts.mute(True) # 静音
chrome_opts.no_imgs(False)
chrome_opts.set_argument("--disable-gpu")
chrome_opts.set_argument('--ignore-certificate-errors')
chrome_opts.set_argument("--proxy-server=http://127.0.0.1:7890")
chrome_opts.incognito(True)
chrome_opts.set_browser_path(r"C:\Program Files\Google\Chrome\Application\chrome.exe")
# chrome_opts.auto_port(True)
browser = Chromium(addr_or_opts=chrome_opts)
search_keyword = "www.yunzhiju.net/zxysx/11456.html"
tab = browser.new_tab("https://www.baidu.com/")
tab.ele("#kw").input(f"{search_keyword}\n", clear=True)
print("before wait")
tab.wait.eles_loaded([".content_none", "#content_left"], any_one=True)
print("after wait")
tools = tab.eles('.:c-tools')
print(tools)
tab.wait(1)
if tools:
tool = tools[0]
tool.hover(0, 0)
tool.click(True)
tips = tab.eles(".c-tip-menu")
print("tips:", tips)
if tips:
tip = tips[0]
temp = tip.ele("t:a@@text()=举报")
print(temp)
href = temp.attr("href")
print(f"href={href}")
# tools = tab.eles(".c-tools")
# print(tools)
# for tool in tools:
# tool.hover(1,1)
#
# for x in tab.eles("t:a@@text()=举报"):
# print(x)