使用ghost.py模拟点击后如何访问网页内容

1 投票
1 回答
1425 浏览
提问于 2025-04-17 14:02

我正在用Ghost.py模拟点击一个按钮。但是我不知道怎么获取点击按钮后加载的内容。

from ghost import Ghost

ghost = Ghost(wait_timeout=40)
page, extra_resources = ghost.open("http://www.samsung.com/in/consumer/mobile-phone/mobile-phone/viewall")
#ghost.wait_page_loaded()
n=2;

print type(ghost.click("input#txtViewAll"))

接下来我该怎么做才能获取动态加载的内容呢?

附注:我在谷歌上查过,没找到答案。

提前谢谢大家!

1 个回答

2

我觉得这个应该是答案:

page, resources = ghost.evaluate(
    "document.getElementById('txtViewAll').click();", expect_loading=True)

祝好,

撰写回答