不在openshift中运行Twill(AttributeError:' ResultWrapper'对象没有属性' page')

时间:2014-08-03 18:33:48

标签: ssh openshift twill

我有一些代码n openshfift正在使用python程序的twill模块,所以我安装了斜纹但我可以,通过ssh模式运行一个简单的斜纹命令代码是:

import twill, os
#os.environ['http_proxy']='http://222.66.115.233:80'
t_com = twill.commands

## get the default browser
t_brw = t_com.get_browser()
## open the url
url = 'http://ieeexplore.ieee.org/xpl/articleDetails'
t_brw.go(url)
html = t_brw.result.page
print html

,错误是(AttributeError:'ResultWrapper'对象没有属性'page'):

>>> import twill, os
os.environ['http_proxy']='http://222.66.115.233:80'
t_com = twill.commands

## get the default browser
t_brw = t_com.get_browser()
## open the url
url = 'http://ieeexplore.ieee.org/xpl/articleDetails'
url= 'www.google.com'
t_brw.go(url)
html = t_brw.result.page
print html
>>> #os.environ['http_proxy']='http://222.66.115.233:80'
... t_com = twill.commands
>>>
>>> ## get the default browser
... t_brw = t_com.get_browser()
>>> ## open the url
>>> url= 'www.google.com'
>>> t_brw.go(url)
==> at http://www.google.com/
>>> html = t_brw.result.page
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'ResultWrapper' object has no attribute 'page'
>>> print html
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'html' is not defined
>>>

所以任何身体都知道如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

由于错综复杂的斜纹版本匹配,它无效。我在笔记本电脑中使用了斜纹“0.9.1”,并在我的openshift应用程序中使用斜纹“1.8.0”。所以我将第二个斜纹更改为'0.9.1'版本并且它有效。 它的回应是:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Draft//EN">
<HTML>
<HEAD>
<TITLE>Error 404--Not Found</TITLE>
<META NAME="GENERATOR" CONTENT="WebLogic Server">
</HEAD>
<BODY bgcolor="white">
<FONT FACE=Helvetica><BR CLEAR=all>
<TABLE border=0 cellspacing=5><TR><TD><BR CLEAR=all>
<FONT FACE="Helvetica" COLOR="black" SIZE="3"><H2>Error 404--Not Found</H2>
</FONT></TD></TR>
</TABLE>
<TABLE border=0 width=100% cellpadding=10><TR><TD VALIGN=top WIDTH=100% BGCOLOR=
white><FONT FACE="Courier New"><FONT FACE="Helvetica" SIZE="3"><H3>From RFC 2068
 <i>Hypertext Transfer Protocol -- HTTP/1.1</i>:</H3>
</FONT><FONT FACE="Helvetica" SIZE="3"><H4>10.4.5 404 Not Found</H4>
</FONT><P><FONT FACE="Courier New">The server has not found anything matching th
e Request-URI. No indication is given of whether the condition is temporary or p
ermanent.</p><p>If the server does not wish to make this information available t
o the client, the status code 403 (Forbidden) can be used instead. The 410 (Gone
) status code SHOULD be used if the server knows, through some internally config
urable mechanism, that an old resource is permanently unavailable and has no for
warding address.</FONT></P>
</FONT></TD></TR>
</TABLE>

</BODY>
</HTML>