dongpo2002 2019-05-15 08:35
浏览 81

解析RSS提要URL不会在浏览器和CURL中返回任何结果,但会在RSS提要阅读器中返回正确的结果

I'm trying to make a parser for a Kijiji RSS feed. The issue I'm having is that for some reason their RSS URL returns no results in a browser or in my script using CURL. However, if I parse the URL with a proper RSS Reader it works perfectly.

Here is an example URL https://www.kijiji.ca/rss-poa/u1001906046 It should return the following returns as an RSS feed https://www.kijiji.ca/o-tork-parts/1001906046. The problem is that when I load the RSS URL in a browser it returns no ad listings. When I load the RSS URL at https://codebeautify.org/rssviewer I see all the results.

My initial thought that I must pass the proper Accept and User-Agent headers. I created my own RSS page to sniff out what headers Code Beautify passes. I got Accept: */* and a blank user agent. I used that with my code, but still getting the same page with no listings.

My code looks like this

$url = "https://www.kijiji.ca/rss-poa/u1001906046";

$headers = array(
    'Accept: */*',
);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_USERAGENT,'');
$result = curl_exec($ch);
curl_close($ch);

echo $result;

What am I doing wrong?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 远程桌面文档内容复制粘贴,格式会变化
    • ¥15 关于#java#的问题:找一份能快速看完mooc视频的代码
    • ¥15 这种微信登录授权 谁可以做啊
    • ¥15 请问我该如何添加自己的数据去运行蚁群算法代码
    • ¥20 用HslCommunication 连接欧姆龙 plc有时会连接失败。报异常为“未知错误”
    • ¥15 网络设备配置与管理这个该怎么弄
    • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
    • ¥20 西门子S7-Graph,S7-300,梯形图
    • ¥50 用易语言http 访问不了网页
    • ¥50 safari浏览器fetch提交数据后数据丢失问题