苏飞论坛

 找回密码
 马上注册

QQ登录

只需一步,快速开始

分布式系统框架(V2.0) 轻松承载百亿数据,千万流量!讨论专区 - 源码下载 - 官方教程

HttpHelper爬虫框架(V2.7-含.netcore) HttpHelper官方出品,爬虫框架讨论区 - 源码下载 - 在线测试和代码生成

HttpHelper爬虫类(V2.0) 开源的爬虫类,支持多种模式和属性 源码 - 代码生成器 - 讨论区 - 教程- 例子

httphelper怎么重定向到一个指定的url?

查看数: 16895 | 评论数: 12 | 收藏 0
关灯 | 提示:支持键盘翻页<-左 右->
    组图打开中,请稍候......
发布时间: 2015-12-16 15:07

正文摘要:

各位大侠,下午好!我自己get一个url,然后用转变工具抓包,发现RedirectURL为A(url),Cookie没有值, 同样的url我直接用浏览器去访问抓包,发现RedirectURL为B(url),Cookie有值,这是为什么呢?是不是httphelpe ...

回复

justinpanrobot 发表于 2016-2-12 20:02:53
谢谢各位的关注,已经解决了。
justinpanrobot 发表于 2015-12-19 22:00:06
站长苏飞 发表于 2015-12-17 13:56
Cookie只使用需要的,一般为第一次的,而不需要对接,你抓包看看那里有返回,提前时需要那个Cookie,能清楚 ...

飞哥,关于这个问题,我发更详细的帖子:http://www.sufeinet.com/thread-14933-1-1.html
有时间你帮我看看好吗?非常感谢
justinpanrobot 发表于 2015-12-17 14:47:07
刚刚发的  图片没有显示在一块,在下面哦
站长苏飞 发表于 2015-12-17 13:56:09
Cookie只使用需要的,一般为第一次的,而不需要对接,你抓包看看那里有返回,提前时需要那个Cookie,能清楚,应该还是Cookie问题。搞的这么神秘,直接公开网址看看就是了
justinpanrobot 发表于 2015-12-17 11:50:24
站长苏飞 发表于 2015-12-17 11:21
手动设置啊,每一次都有cookie带入我输出的,

            
             HttpHelper httpHelper = new HttpHelper();
             HttpItem item = new HttpItem
             {
                 URL = url,
                 Method = "get",
                 IsToLower = false,
                 Referer = referer,
                 Timeout = this.timeout,
                 ReadWriteTimeout = this.readWriteTimeout,
                 UserAgent = this.userAgent,
                 ContentType = this.contentType,
                 Allowautoredirect = fale,
                 ProxyIp = this.proxy,
                 ResultCookieType = ResultCookieType.CookieCollection,
                 CookieCollection = this.cc_gb,   
                 KeepAlive=true,
                 AutoRedirectCookie=true,     
                 Cookie= this.cookie_gb, //this.cookie_gb为上一次访问cookie              
               
             };

                //----------问题点---------
              /*
               1. item.Cookie="重定向url"   
               2. item.Cookie+="重定向url"   
               2. item.Cookie="name,value=重定向url"   
              或者这是item.Cookie应该怎么设置才能重定向到指定的urlA(默认有重定向urlB)   

            我按群主原来说的方法就是先操作:
             当然Allowautoredirect = fale,
             HttpResult htmlResult = httpHelper.GetHtml(item);
            然后用 htmlResult.RedirectUrl去get,如下:
              item.Cookie+= oldCookie; //用上次cookie
             HttpResult html = httpHelper.GetHtml(htmlResult.RedirectUrl);
   
           这样结果还是不行         
             */

             //-------请求----------   
             HttpResult html = httpHelper.GetHtml(item);
站长苏飞 发表于 2015-12-17 11:21:51
justinpanrobot 发表于 2015-12-17 10:26
这似乎是要修改cookie?   我抓包发现在不设置coolie情况下重定向到a1,修改cookie后重定向到设置的url,但 ...

手动设置啊,每一次都有cookie带入我输出的,
justinpanrobot 发表于 2015-12-17 10:26:50
这似乎是要修改cookie?   我抓包发现在不设置coolie情况下重定向到a1,修改cookie后重定向到设置的url,但这时候cookie应该怎么设置呢?在线等待,万分感谢!
justinpanrobot 发表于 2015-12-17 10:21:06
站长苏飞 发表于 2015-12-17 09:29
关键是没有见你这么写啊,你贴下代码,或者贴下抓的包看看

楼主 ,大体意思是这样的:
我get一个网址a,然后a自动重定向到一个网站a1,现在我想同样访问网址a但修改这个重定向到a2,那应该怎么做呢?

QQ|手机版|小黑屋|手机版|联系我们|关于我们|广告合作|苏飞论坛 ( 豫ICP备18043678号-2)

GMT+8, 2025-2-23 00:57

© 2014-2021

快速回复 返回顶部 返回列表