python - 如何在linux中像在windows浏览器中打开html页面一样打开html页面?

标签 python linux selenium

我有一个名为 temp.html 的 html 页面,它喜欢:

<div class="file_div1" style="border-top:none; margin-top:0">
    <div class="file_div1_1">
        <script type="text/javascript">
            var file_id=1001;
        </script>
        <script language='JavaScript' type='text/javascript' src='http://files.testjs.com/cs/jsfile/js/f.js'></script>
    </div>
</div>

这些 html 片段会触发一个 http 请求,其 url 如下:

http://ff.test.com/rf?id=1001

我在win7中更改hosts文件并将“ff.test.com”重定向到10.1.120.81(这是我的离线linux机器),然后我在firefox中使用python + selenium打开这个html页面,http请求将发送到10.1.120.81。

但是,使用python + selenium 速度很慢,如果我想在linux中这样做,我该怎么办?

我尝试在离线linux机器中使用python中的urllib2或wget命令,不幸的是,http请求可以发送到10.1.120.81,并且我只能获取静态html页面,但无法执行它。

还有其他方法吗?谢谢!

最佳答案

等等,我不太明白你的意思。您是否处于窗口环境(X11)?或者只是命令行?

例如,如果您想执行 html 文件以便运行 javascript,您可以使用模仿 Web 浏览器的东西;山猫,甚至 curl ?

我认为。我不太明白这个问题,但这也许有帮助!

关于python - 如何在linux中像在windows浏览器中打开html页面一样打开html页面?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21176361/

相关文章:

linux - bc 忽略比例选项

javascript - 如何使用 PhantomJS 和 Selenium 浏览页面

java - 如何限制控制流不应该来到After方法中以防出现异常

python - 将分层数据存储到 hdf5 - 如何构建它们

python - 如何使用 Twitter Python 库发送表情符号

python - 如何在python中拆分字母数

php - 在 apache 中出现任何错误时显示 500 错误

python - 使用 python 或 linux 终端连接 wifi

python - 在重构我的 python 脚本时需要帮助

ruby - `selenium-webdriver` ruby​​ gem 无法与 Ubuntu 14.04 上的 chromedriver 连接