2012-02-07 58 views
2

1我收到以下错误:获取InvalidURLError:的ApplicationError:在网址提取

InvalidURLError: ApplicationError: 1 

经过我的代码,并记录了一些各种各样的事情和URL的造成这种错误的出现看起来非常正常。通过urllib.quote引用它们,并通过浏览器访问它们会产生正常结果。

错误发生在很多网址上,而不是一个。该URL指向一个API服务,并在应用程序内构建。

顺便说一句,这是一个链接到google.appengine.api.urlfetch源代码:http://code.google.com/p/googleappengine/source/browse/trunk/python/google/appengine/api/urlfetch.py?r=56

文档字符串表示在下列情况下应该发生错误:“InvalidURLError,如果URL无效。”和“如果URL是一个空字符串或明显无效的,我们抛出一个urlfetch.InvalidURLError”

只是为了简单对于那些想测试一下这个谁:

url = 'http://api.embed.ly/1/oembed?key=REMOVEDKEY&maxwidth=400&urls=http%3A//V.interesting.As,http%3A//abcn.ws/z26G9a,http%3A//apne.ws/z37VyP,http%3A//bambuser.com/channel/baba-omer/broadcast/2348417,http%3A//bambuser.com/channel/baba-omer/broadcast/2348417,http%3A//bambuser.com/channel/baba-omer/broadcast/2348417,http%3A//bbc.in/xFx3rc,http%3A//bbc.in/zkkLJq,http%3A//billingsgazette.com/news/local/former-president-bush-to-speak-at-billings-fundraiser-in-may/article_f7ef425a-349c-56a9-a399-606b48033f35.html,http%3A//billingsgazette.com/news/local/former-president-bush-to-speak-at-billings-fundraiser-in-may/article_f7ef425a-349c-56a9-a399-606b48033f35.html,http%3A//billingsgazette.com/news/local/friday-forecast-calls-for-cloudy-windy-day-nighttime-snow-possible/article_d3eb3159-68b0-5559-8255-03fce56eaedd.html,http%3A//billingsgazette.com/news/local/gallery-toy-run/collection_f5042a31-bfd4-5f63-a901-2a8c3e8fb26a.html%230,http%3A//billingsgazette.com/news/local/gas-prices-continue-to-drop-in-billings/article_4e8fd07e-0e1e-5c0e-b551-4162b60c4b60.html,http%3A//billingsgazette.com/news/local/gas-prices-continue-to-drop-in-billings/article_713a0c32-32c9-59f1-9aeb-67b8462bbe88.html,http%3A//billingsgazette.com/news/local/gas-prices-continue-to-fall-in-billings-area/article_2bdebf4b-242c-569e-b414-f388a48f4a14.html,http%3A//billingsgazette.com/news/local/gas-prices-dip-below-a-gallon-at-some-billings-stations/article_c7f4d373-dc2b-55c0-b457-10346c0274a6.html,http%3A//billingsgazette.com/news/local/gas-prices-keep-dropping-in-billings-area/article_3666cf9c-4552-5108-9d5c-de2bba12fa3f.html,http%3A//billingsgazette.com/news/local/government-and-politics/city-picks-st-vincent-as-care-provider-for-health-insurance/article_a899f885-15e1-5b98-b899-75acc01e8feb.html,http%3A//billingsgazette.com/news/local/government-and-politics/linder-settles-in-after-first-year-as-sheriff/article_55a9836e-2196-546d-80f0-48bdef717fa3.html,http%3A//billingsgazette.com/news/local/government-and-politics/new-council-members-city-judge-sworn-in/article_bb7ac948-1d45-579c-a057-1323fb2e643d.html' 
from google.appengine.api import urlfetch 
result = urlfetch.fetch(url=url) 

这里的回溯: 回溯(最近一次通话最后): 文件“”,第1行,在 文件“/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/api/urlfetch .py“,第263行,在获取返回rpc.get_result() 文件”/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-de fault.bundle /内容/资源/ google_appengine /谷歌/应用服务引擎/ API/apiproxy_stub_map.py “线路592,在get_result 回归自我.__ get_result_hook(个体经营) 文件” /Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine- default.bundle /内容/资源/ google_appengine /谷歌/应用服务引擎/ API/urlfetch.py​​”,线路359,在_get_fetch_result 提高InvalidURLError(STR(ERR)) InvalidURLError:的ApplicationError:1

我不知道这件事情很简单,我从这一切都失踪了。希望你的意见和想法。谢谢!

+1

发布的URL是invlid,你可能会遇到国际字符的问题。 – 2012-02-07 09:58:58

+0

嘿,谢伊,加了它... – 2012-02-07 10:02:02

+0

你有没有找到这个解决方案?我的意思是,如果你可以使用大于20148字符的URL。 – 2014-09-14 18:59:01

回答

2

您的网址太长,there is a limit on the length of URLs

+0

谢谢谢,你知道限制是什么吗? – 2012-02-07 10:20:39

+1

2000字左右 – 2012-02-07 10:26:02

+0

THANKs,根据这个http://stackoverflow.com/questions/1051485/what-is-the-character-limit-on-url它是2048 – 2012-02-07 11:30:37