【问题标题】:google app engine apps not allowed to make request to craigslist谷歌应用引擎应用程序不允许向 craigslist 提出请求
【发布时间】:2014-07-08 23:11:14
【问题描述】:

我正在用 php 解析来自网站的 rss

$url = 'http://seattle.craigslist.org/search/sss?query=furniture&s=0&format=rss';
$result = file_get_contents($url);

这在本地运行良好,但在部署到 GAE 后,$result 只返回换行符。 \r\n

我还在脚本顶部设置了 libxml_disable_entity_loader(false)。

编辑: 我发现了问题。 Craigslist 正在阻止谷歌应用引擎应用程序。一旦我切换到“http://feeds.abcnews.com/abcnews/sportsheadlines”,它就可以工作了。但完全相同的代码不适用于“http://seattle.craigslist.org/search/sss?query=furniture&s=0&format=rss”。 我可能是错的,如果有人能告诉我更多关于它的信息,我将不胜感激。谢谢。

【问题讨论】:

  • libxml_disable_entity_loader — 禁用加载外部实体的能力。请注意,这也会禁用 url 加载。
  • 不熟练使用 PHP,也不完全确定为什么这不起作用,但与官方 App Engine 网站上的 URLFetch 示例有很多不同。我建议你看看。链接:developers.google.com/appengine/docs/php/urlfetch
  • 您是否尝试将“http://”前缀添加到 $url?
  • 是的,我在 url 中有前缀 http:// 前缀。我想我找到了问题,它是 craigslist 阻止了谷歌应用引擎应用程序。一旦我将 url 切换到其他一些 rss (abc news feed) ,它就可以工作了。

标签: php google-app-engine


【解决方案1】:

无论出于何种原因,来自 AppEngine 的 Craigslist 404 请求。如果我将开发环境中的用户代理切换到 AppEngine 以外的其他东西,它可以工作文件。

【讨论】:

    猜你喜欢
    • 2023-03-30
    • 2011-12-20
    • 2012-08-13
    • 2014-03-01
    • 1970-01-01
    • 2014-05-25
    • 1970-01-01
    • 2017-04-10
    • 1970-01-01
    相关资源
    最近更新 更多