为什么不在python 2.4.3中 [英] why not in python 2.4.3

查看:85
本文介绍了为什么不在python 2.4.3中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我从2.4.2升级到python 2.4.3。

我想从谷歌新闻中获取一些原子提要,其功能如同

这个

import urllib2

def takefeed(url):

request = urllib2.Request(url)

request.add_header(''User-Agent'',''Mozilla / 4.0(兼容; MSIE 5.5;

Windows NT'')

揭幕战= urllib2.build_opener()

data = opener.open(request).read()

返回数据

url =''http: //news.google.it/?output=rss''

d = takefeed(url)

这与python 2.3.5很好用,但不适用于2.4。 3.

为什么?

谢谢

解决方案



Rocco写道:


我从2.4.2升级到python 2.4.3。
我想从谷歌新闻中获取一些原子源功能如
这个
导入urllib2
def takefeed(url):
request = urllib2.Request(url)
request.add_header(''User-Agent'',''Mozilla / 4.0(兼容; MSIE 5.5;
Windows NT'')
opener = urllib2.build_opener()
data = opener.open(request).read()
返回数据
url =''http://news.google.it/?output = rss''
d = takefeed(url)
这与python 2.3.5很好用,但不适用于2.4.3。
为什么?




定义woks [sic] well。它在2.4.3上工作正常(并且通过工作

罚款我的意思是它没有例外地运行它返回了出现的

是RSS数据) 。如果你给我们一个例外追踪,它会帮助你多付b $ b。


也许Google的服务器(或你的ISP)已经关闭了。发生这种情况

有时候。


Carl


Rocco:

但不适用于2.4.3。




定义不起作用。


- -
$ b $bRenéPijlman


这是运行函数时的问题

这是2.3的结果。 5

print rss
<?xml version =" 1.0" encoding =" UTF-8">< feed version =" 0.3" xml:lang =" it"

xmlns =" http://purl.org/atom/ns#">< generator> NFE / 1.0< / generator>< title> Google

新闻意大利< / title>< link rel =" alternate" type =" text / html"

href =" http://news.google.it/" />< tagline> Google新闻

Italia< ; / tagline>< author>< name> Google

Inc.< / name>< email> ne *********** @ google.com< /电子邮件>< / author>< copyright>& amp; copy; 2006

Google< / copyright>< modified> 2006-05-28T19:09:13 + 00:00< /修改后的>

<! - 几个笔记:

*添加一个output = atom获取Atom的参数

*部分页面有一个topic =? param;

使用" topic = h"最佳故事部分。

- >< entry>< title> Benedetto XVI:Wojtyla santo subito - Libert ??

< / title>< ; link rel =" alternate" type =" text / html"

href =" http://www.liberta.it/default.asp?IDG = 605282024" />< id> tag:news.google .com,2005:cluster = 41b535fb< / id>< summary> Prima

pagina< / summary>< issued> 2006-05-28T11:05:00 + 00:00< / issued> ;< modified> 2006-05-28T11:05:00 + 00:00< / modified>< content

type =" text / html" mode =" escaped">& lt; br& gt;& lt; table border = 0 align =

cellpadding = 5 cellspacing = 0& gt;& lt; tr& gt ;& lt; td width = 80 align = center

valign = top& gt;& lt; a .....

import sys
sys.getdefaultencoding()
''ascii''
这是2.4.3打印rss
的结果????? rss
''\ x1f \ x8b \ x08 \ x00 \ x00 \ x00 \ x00 \ x00 \ x02 \ xff \ xe5} Ks \ x e3F \ xb6 \\ \\ xe6 \ xfeF \ xdc \ xff \ x90 \ xd77 \ xba \ xc3 \ x9e \\ xxD \ xbc \ x \\ n \\ x \\ xx \\ x \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ xa2\xd4

hi
I made the upgrade to python 2.4.3 from 2.4.2.
I want to take from google news some atom feeds with a funtion like
this
import urllib2
def takefeed(url):
request=urllib2.Request(url)
request.add_header(''User-Agent'', ''Mozilla/4.0 (compatible; MSIE 5.5;
Windows NT'')
opener = urllib2.build_opener()
data=opener.open(request).read()
return data
url=''http://news.google.it/?output=rss''
d=takefeed(url)
This woks well with python 2.3.5 but does not work with 2.4.3.
Why?
Thanks

解决方案


Rocco wrote:

hi
I made the upgrade to python 2.4.3 from 2.4.2.
I want to take from google news some atom feeds with a funtion like
this
import urllib2
def takefeed(url):
request=urllib2.Request(url)
request.add_header(''User-Agent'', ''Mozilla/4.0 (compatible; MSIE 5.5;
Windows NT'')
opener = urllib2.build_opener()
data=opener.open(request).read()
return data
url=''http://news.google.it/?output=rss''
d=takefeed(url)
This woks well with python 2.3.5 but does not work with 2.4.3.
Why?



Define "woks [sic] well". It works fine for me on 2.4.3 (and by "works
fine" I mean it ran without an exception and it returned what appeared
to be RSS data). If you would give us an exception trace it would help
a lot.

Maybe Google''s server (or your ISP''s) was down. That happens
sometimes.

Carl


Rocco:

but does not work with 2.4.3.



Define "does not work".

--
René Pijlman


This is the problem when I run the function
this is the result from 2.3.5

print rss <?xml version="1.0" encoding="UTF-8"?><feed version="0.3" xml:lang="it"
xmlns="http://purl.org/atom/ns#"><generator>NFE/1.0</generator><title>Google
News Italia</title><link rel="alternate" type="text/html"
href="http://news.google.it/"/><tagline>Google News
Italia</tagline><author><name>Google
Inc.</name><email>ne***********@google.com</email></author><copyright>&amp;copy;2006
Google</copyright><modified>2006-05-28T19:09:13+00:00</modified>
<!-- A couple notes:
* add an "output=atom" param to get Atom
* section pages have a "topic=?" param;
use "topic=h" for a Top Stories section.
--><entry><title>Benedetto XVI: Wojtyla santo subito - Libert??
</title><link rel="alternate" type="text/html"
href="http://www.liberta.it/default.asp?IDG=605282024"/><id>tag:news.google.com,2005:cluster=41b535fb</id><summary>Prima
pagina</summary><issued>2006-05-28T11:05:00+00:00</issued><modified>2006-05-28T11:05:00+00:00</modified><content
type="text/html" mode="escaped">&lt;br&gt;&lt;table border=0 align=
cellpadding=5 cellspacing=0&gt;&lt;tr&gt;&lt;td width=80 align=center
valign=top&gt;&lt;a .....
import sys
sys.getdefaultencoding() ''ascii'' this is the result with 2.4.3 print rss ??? rss ''\x1f\x8b\x08\x00\x00\x00\x00\x00\x02\xff\xe5}Ks\x e3F\xb6\xe6\xfeF\xdc\xff\x90\xd77\xba\xc3\x9e\x10D \xbc\x01\xcaU\xee\xa1\x9eM[\xa2\xd4


这篇关于为什么不在python 2.4.3中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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