http://www.sufeinet.com/plugin.php?id=keke_group

苏飞论坛

 找回密码
 马上注册

QQ登录

只需一步,快速开始

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

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

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

查看: 3735|回复: 4

[学生提问] post如何判断成功 对象以移动

[复制链接]
发表于 2015-2-12 14:29:10 | 显示全部楼层 |阅读模式
1金钱
1.png post完了返回的html提示对象以移动是不是302跳转了怎么才能确认是否post成功



1. 开通SVIP会员,免费下载本站所有源码,不限次数据,不限时间
2. 加官方QQ群,加官方微信群获取更多资源和帮助
3. 找站长苏飞做网站、商城、CRM、小程序、App、爬虫相关、项目外包等点这里
发表于 2015-2-12 14:40:33 | 显示全部楼层
访问一个需要Post成功才能访问的地方就知道了吧
回复

使用道具 举报

 楼主| 发表于 2015-2-12 15:34:35 | 显示全部楼层
我访问了 他直接跳转到登录界面了 应该是没有成功 还是需要加上cookie访问
回复

使用道具 举报

 楼主| 发表于 2015-2-12 16:21:37 | 显示全部楼层
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CsharpHttpHelper;
namespace post
{
    class Program
    {
        
        static void Main(string[] args)
        {

            HttpHelper http = new HttpHelper();
            HttpItem item = new HttpItem()
            {
                URL = "http://user.ynshangji.com/viplogin.jsp",
                Method = "post",
                Postdata = "beforUrl=&cookie_value=aoruide1&userpass=aoruide1234",
                Accept = "text/html, application/xhtml+xml, */*",
                Referer = "http://user.ynshangji.com/vip.html",
                UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)",
                ContentType = "application/x-www-form-urlencoded",
                Host = "user.ynshangji.com",
                Connectionlimit = 2014,



            };
            item.Encoding = Encoding.GetEncoding("gb2312");
            HttpResult result = http.GetHtml(item);
            string cookie = result.Cookie;

            
                       HttpItem item1 = new HttpItem()
            {
                URL = "http://user.ynshangji.com/user/user_edit1.asp?userno=412634&usercode=aoruide1&userflag=1",//URL     必需项   
                Method = "get",//URL     可选项 默认为Get   
                ContentType = "text/html",//返回类型    可选项有默认值  
                Cookie=cookie,
                //ContentType = "application/x-www-form-urlencoded",//返回类型    可选项有默认值   
            };
            //请求的返回值对象
            HttpResult result1 = http.GetHtml(item);
            //获取请请求的Html
            string html1 = result.Html;
            //获取请求的Cookie
            string cookie1 = result.Cookie;
            Console.WriteLine(html1);

        }

    }
}
回复

使用道具 举报

 楼主| 发表于 2015-2-12 16:21:48 | 显示全部楼层
还是提示对象以移动
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 马上注册

本版积分规则

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

GMT+8, 2024-5-15 16:17

© 2014-2021

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