Linuxkey007 / opm-server-mirror

Automatically exported from code.google.com/p/opm-server-mirror
0 stars 0 forks source link

Python版本的代码 #11

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
这是python版本的代码,看到svn库里似乎有,但好像代码有问��
�且不够简炼,自己写
了个,实测通过,希望能merge进去

Original issue reported on code.google.com by ayanamist on 30 Apr 2010 at 4:53

Attachments:

GoogleCodeExporter commented 8 years ago
你这个python代码使用的时候,是不是地址变成根目录了??��
�如:http://xxxxx.appspot.com/
而不是和以前的那个JAVA的http://xxxxxxxxxxxxxxxx.appspot.com/opm

Original comment by lanbo2485@gmail.com on 18 May 2010 at 10:16

GoogleCodeExporter commented 8 years ago
是的。用的是根目录。因为这个是我自己写的,不知道原来Ja
va版是什么个状况

Original comment by ayanamist on 18 May 2010 at 1:02

GoogleCodeExporter commented 8 years ago
呵呵,我测试成功了,用根目录的办法非常好,因为我用的��
�WM的OPM,长度有限,这点还真的感
谢你。但是有一个问题,据说以前的PHP版本也有过,不知道��
�否解决,就是所有的表单操作都无
法发送。比如推特,输入用户名和密码,sign 
in的时候,就显示网络错误了,只要不提交表单就
没有问题。

Original comment by lanbo2485@gmail.com on 18 May 2010 at 4:49

GoogleCodeExporter commented 8 years ago
更正我上面的帖子,我提交着,提交着,就这么可以了,但��
�成功率极低呀,提交十次登陆大概
得两次……很多网站一次访问成功的概率也很低。。。。

Original comment by lanbo2485@gmail.com on 18 May 2010 at 4:53

GoogleCodeExporter commented 8 years ago
这个大概是Opera服务器那边的限制。我也发现了这个问题……
我现在只把它当翻墙浏览器用

Original comment by ayanamist on 19 May 2010 at 12:30

GoogleCodeExporter commented 8 years ago
Traceback (most recent call last):
  File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/webapp/__init__.py", line 634, in __call__
    handler.get(*groups)
  File "/base/data/home/apps/xxxxxxxxxxx/1.343915376060018391/index.py", line 15, in get
    self.response.status = '200 OK'
AttributeError: can't set attribute

求修复!

Original comment by jak...@gmail.com on 2 Apr 2011 at 1:10

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
自己搞定了、、

#!/usr/bin/env python
# -*- coding: UTF-8 -*-

import wsgiref.handlers, urlparse
from google.appengine.ext import webapp
from google.appengine.api import urlfetch

class MainPage(webapp.RequestHandler):
    def post(self):
        headers={'Content-Type':'application/xml'}
        data = urlfetch.fetch(
                        'http://server4.operamini.com', 
                        payload=self.request.body, 
                        method=urlfetch.POST, 
                        deadline=8,
                        follow_redirects=True,
                        headers={
                        'Connection': 'Keep-Alive',
                        'Content-Type': 'application/xml',
                        'User-Agent': 'Java0'})
        self.response.status_code = data.status_code
        self.response.headers.add_header('Content-Type', 'application/octet-stream')
        self.response.headers.add_header('Cache-Control', 'private, no-cache')
        self.response.out.write(data.content)

    def get(self):
        self.response.status_code = 200
        self.response.headers.add_header('Content-Type', 'text/html')
        self.response.out.write('This is Opera Mini Server Proxy!')

def main():
    application = webapp.WSGIApplication( [(r'/.*', MainPage)], debug=True)
    wsgiref.handlers.CGIHandler().run(application)

if __name__ == "__main__":
    main()

Original comment by jak...@gmail.com on 3 Apr 2011 at 2:11

GoogleCodeExporter commented 8 years ago
Traceback (most recent call last):
  File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/webapp/__init__.py", line 634, in __call__
    handler.get(*groups)
  File "/base/data/home/apps/xinying-api/1.349464783147638407/main.py", line 134, in get
    self.do_proxy('GET')
  File "/base/data/home/apps/xinying-api/1.349464783147638407/main.py", line 95, in do_proxy
    return success_output(self, gtap_message )
  File "/base/data/home/apps/xinying-api/1.349464783147638407/main.py", line 34, in success_output
    handler.response.status = '200 OK'
AttributeError: can't set attribute

這怎麽囘事啊

Original comment by xinying0...@gmail.com on 3 Apr 2011 at 7:29

GoogleCodeExporter commented 8 years ago
10L,请使用 9L 的修复代码(main.py)、、

Original comment by jak...@gmail.com on 4 Apr 2011 at 10:01

GoogleCodeExporter commented 8 years ago
请问11L,那个main.py的文件是只把你写的这些进行修改就可以�
��?还是说直接就复制了使用你的这个做为main.py就可以了呢��
�

Original comment by Winston...@gmail.com on 4 Apr 2011 at 12:31

GoogleCodeExporter commented 8 years ago
12L 
直接复制即可、原本的代码量就很少的,就全贴上来了、、

Original comment by jak...@gmail.com on 6 Apr 2011 at 4:05

GoogleCodeExporter commented 8 years ago
贴个更新后的代码、、

#!/usr/bin/env python
# -*- coding: UTF-8 -*-

import wsgiref.handlers, urlparse
from google.appengine.ext import webapp
from google.appengine.api import urlfetch

class MainPage(webapp.RequestHandler):
    def post(self):
        headers={'Content-Type':'application/xml'}
        data = urlfetch.fetch(
                        'http://server4.operamini.com', 
                        payload=self.request.body, 
                        method=urlfetch.POST, 
                        deadline=30,
                        follow_redirects=True,
                        headers={
                        'Connection': 'Keep-Alive',
                        'Content-Type': 'application/xml',
                        'User-Agent': 'J2ME/MIDP'})
        self.response.set_status(data.status_code)
        self.response.headers.add_header('Content-Type', data.headers['content-type'])
        self.response.headers.add_header('Cache-Control', 'private, no-cache')
        self.response.out.write(data.content)

    def get(self):
        self.response.set_status(200)
        self.response.headers.add_header('Content-Type', 'text/html')
        self.response.out.write('This is Opera Mini Server Proxy!')

def main():
    application = webapp.WSGIApplication( [(r'/.*', MainPage)], debug=True)
    wsgiref.handlers.CGIHandler().run(application)

if __name__ == "__main__":
    main()

Original comment by jak...@gmail.com on 24 Apr 2011 at 11:48

GoogleCodeExporter commented 8 years ago
以前用opera 
mini,后来不能用了,前几天才知道可以用php中转的方法,试�
��php中转已经成功。
现在我有一个cgi的空间,想做一个用perl中转的程序,比着php�
��那个写了一个,没有测试成功,代码贴上来,请帮忙修改!

#!/usr/bin/perl
use LWP;
use LWP::UserAgent;

my $browser = new LWP::UserAgent(keep_alive => 1);
push @{$browser->requests_redirectable}, 'POST';

my $url = 'http://82.145.209.253';
my $header =new HTTP::Headers;

if($ENV{'REQUEST_METHOD'}eq"GET"){
print "Location: http://www.google.com\n\n";
}
elsif($ENV{'REQUEST_METHOD'}eq"POST"){

read(STDIN,$buffer,$ENV{'CONTENT_LENGTH'});

$header->content_type('application/xml');
$header->user_agent('Java0');
$header->content_length(length($buffer));

$request = HTTP::Request->new(POST=>$url,$header,$buffer); 

$response = $browser->request($request); 

print "Cache-Control: private, no-cache\n";
print "Content-Type: application/octet-stream\n\n";

print $response->content;
}

Original comment by zkwan...@gmail.com on 28 Apr 2011 at 7:33

GoogleCodeExporter commented 8 years ago
这几天在用国外http代理连opm的原服F墙,这种方法比搭建中转
容易多了

Original comment by zkwan...@gmail.com on 11 Jun 2011 at 9:16

GoogleCodeExporter commented 8 years ago
Error: Server Error

The server encountered an error and could not complete your request.
If the problem persists, please report your problem and mention this error 
message and the query that caused it.
怎么办?

Original comment by wuyafei0...@gmail.com on 23 Jul 2011 at 3:00

GoogleCodeExporter commented 8 years ago
和17L一样的问题,怎么解决?

Original comment by fantam...@gmail.com on 8 Feb 2012 at 7:05

GoogleCodeExporter commented 8 years ago
17L/18L,把14L的第12行改为如下试试,注意最后的逗号:
url='http://server4.operamini.com',

Original comment by goodfire...@gmail.com on 9 Feb 2012 at 3:17

GoogleCodeExporter commented 8 years ago
逗号被吃了,我直接贴出来吧。
import wsgiref.handlers, urlparse
from google.appengine.ext import webapp
from google.appengine.api import urlfetch

class MainPage(webapp.RequestHandler):
    def post(self):
        headers={'Content-Type':'application/xml'}
        data = urlfetch.fetch(
                        url='http://server4.operamini.com',
                        payload=self.request.body, 
                        method=urlfetch.POST, 
                        deadline=30,
                        follow_redirects=True,
                        headers={
                        'Connection': 'Keep-Alive',
                        'Content-Type': 'application/xml',
                        'User-Agent': 'Dalvik/1.4.0 (Linux; U; Android 2.3.6)'})
        self.response.set_status(data.status_code)
        self.response.headers.add_header('Content-Type', data.headers['content-type'])
        self.response.headers.add_header('Cache-Control', 'private, no-cache')
        self.response.out.write(data.content)

    def get(self):
        self.response.set_status(200)
        self.response.headers.add_header('Content-Type', 'text/html')
        self.response.out.write('Hello, This is Opera Mini Server Proxy!')

def main():
    application = webapp.WSGIApplication( [(r'/.*', MainPage)], debug=True)
    wsgiref.handlers.CGIHandler().run(application)

if __name__ == "__main__":
    main()

Original comment by goodfire...@gmail.com on 9 Feb 2012 at 3:19

GoogleCodeExporter commented 8 years ago
晕倒,贴整篇代码也会被吃掉逗号!反正url='http://server4.operam
ini.com'这句后面应该有一个逗号!

Original comment by goodfire...@gmail.com on 9 Feb 2012 at 3:21