如何通过cfhttp模拟真实的http请求?
我需要通过 cfhttp 模拟真实的 http 请求。 我正在使用 ColdFusion 获取 rss feed,但今晚他们开始阻止我的请求并发送索引页面作为响应,而不是 rss feed。
我为 cfhttp 添加了 useragent,但没有帮助。
Opera、Firefox 和 Chrome 从同一台计算机正确打开 feed。
I need to emulate a real http request via cfhttp.
I was getting rss feed with ColdFusion, but tonight they started to block my request and send an index page in response instead of rss fead.
I added useragent for cfhttp, but it doesn't help.
Opera, Firefox and Chrome open feed correctly from the same computer.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的,谢谢。我嗅探了浏览器发送到站点的所有 HTTP 标头,然后在 cfhttp 请求中模拟它们。解决办法是:
Yep, thanks. I sniffed all HTTP headers which browser sends to the site and then emulated them in cfhttp request. The solution is:
我猜测具有 RSS 提要的站点仍在嗅探用户代理,并且 CFHTTP 未设置为该站点正在使用的用户代理。使用 HTTP 代理嗅探器(即 Charles HTTP 代理)记录正确显示 RSS 源的浏览器的 HTTP 请求,然后尝试使用 CFHTTP 以及与先前成功请求相同的用户代理字符串。
如果仍然不起作用,请使用 CFHTTP 的“proxyport”和“proxyserver”属性通过 HTTP 嗅探器运行 ColdFusion 请求,并检查以确保用户代理设置正确并与工作请求进行比较。
I would guess that the site with the RSS feed is sniffing the User Agent still, and the CFHTTP one isn't set to one that the site is using. Use a HTTP Proxy Sniffer (ie Charles HTTP Proxy) to record the HTTP request of a browser that is displaying the RSS feed correctly, then try using CFHTTP with the same User Agent string as a previously successful request.
If it still doesn't work, use the 'proxyport' and 'proxyserver' attributes of CFHTTP to run the ColdFusion request through your HTTP sniffer and check to make sure the User Agent is being set correctly and compare to a working request.