如何通过 cfhttp 模拟真实的 http 请求? [英] How to emulate a real http request via cfhttp?

查看:19
本文介绍了如何通过 cfhttp 模拟真实的 http 请求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要通过 cfhttp 模拟一个真实的 http 请求.我正在使用 ColdFusion 获取 rss 提要,但今晚他们开始阻止我的请求并发送一个索引页面作为响应,而不是 rss 提要.

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.

我为 cfhttp 添加了用户代理,但没有帮助.

I added useragent for cfhttp, but it doesn't help.

Opera、Firefox 和 Chrome 从同一台计算机正确打开提要.

Opera, Firefox and Chrome open feed correctly from the same computer.

推荐答案

好的,谢谢.我嗅探了浏览器发送到站点的所有 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:

<cfhttp url="http://example.com/feed" 
useragent="Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/533.7 (KHTML, like Gecko) Chrome/5.0.391.0 Safari/533.7"
result="httpresult"
redirect="false"
>
<cfhttpparam type="header" name="HTTP_REFERER" value="http://example.com/feed/" >
<cfhttpparam type="header" name="Accept-Encoding" value="gzip,deflate,sdch" >
<cfhttpparam type="header" name="Proxy-Connection" value="keep-alive" >
<cfhttpparam type="header" name="Accept" value="application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5">
<cfhttpparam type="header" name="Accept-Language" value="en-US,en;q=0.8">
<cfhttpparam type="header" name="Accept-Charset" value="ISO-8859-1,utf-8;q=0.7,*;q=0.3">
<cfhttpparam type="cookie" name="some-cookie" value="1">

这篇关于如何通过 cfhttp 模拟真实的 http 请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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