通过代码模拟用户浏览 [英] Simulate user browsing by code

查看:52
本文介绍了通过代码模拟用户浏览的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要模拟一个用户像硒一样浏览网页,包括加载iframe,发出ajax请求等.它唯一需要在无GUI的计算机(linux)上运行的问题.有没有简单的方法可以使用python或php做到这一点?请不要告诉我使用xvfb,我已经读过它,这是我的不得已..我很确定应该有一些更简单的方法.

I need to simulate a user browsing a web-page like what selenium does, including loading iframes, making ajax requests etc.. The only problem it needs to run on a GUI-less machine (linux). Is there a simple way to do this with python or php? please don't tell me to use xvfb, I've already read about it, and it's my last resort.. I'm pretty sure that there should be something easier.

推荐答案

您可以使用 Ghost.py 在Python中:

You could use Ghost.py in Python:

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

这将运行一个无头Webkit浏览器,您可以通过Python对其进行控制.

This runs a headless Webkit browser that you can control from Python.

这篇关于通过代码模拟用户浏览的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆