【问题标题】:not runing Twill in openshift ( AttributeError: 'ResultWrapper' object has no attribute 'page')不在openshift中运行斜纹(AttributeError:'ResultWrapper'对象没有属性'page')
【发布时间】:2014-08-03 18:33:47
【问题描述】:

我有一些代码 n openshfift 正在使用 python 程序的斜纹模块,所以我安装了斜纹但我不能通过 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' object has no attribute '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
>>>

那么有没有人知道如何解决这个问题?

【问题讨论】:

    标签: ssh openshift twill


    【解决方案1】:

    由于斜纹版本不匹配而无法正常工作。我在笔记本电脑中使用斜纹“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>
    

    【讨论】:

    • 因为我是问题的所有者!。 (这是我的问题,我找到了答案。)
    • 这确实解释了您如何知道版本号是的。很抱歉错过了这个小事实。
    • 另外,请接受您发布的答案,以便其他人知道该问题已成功回答。
    猜你喜欢
    • 1970-01-01
    • 2022-11-24
    • 2020-08-15
    • 2012-12-01
    • 2021-04-19
    • 2022-09-28
    • 2021-11-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多