0

我需要像 selenium 一样模拟用户浏览网页,包括加载 iframe、发出 ajax 请求等。它需要在无 GUI 的机器(linux)上运行的唯一问题。有没有一种简单的方法可以用 python 或 php 做到这一点?请不要告诉我使用 xvfb,我已经阅读过它,这是我最后的手段。我很确定应该有更简单的东西。

4

1 回答 1

4

你可以在 Python 中使用Ghost.py

from ghost import Ghost
ghost = Ghost()
page, extra_resources = ghost.open("http://jeanphi.fr")
assert page.http_status==200 and 'jeanphix' in ghost.content

这会运行一个可以从 Python 控制的无头 Webkit 浏览器。

于 2013-03-02T17:59:05.917 回答