日期:2014-05-17  浏览次数:21108 次

请求达人,POST的网页数据如何获取?
如下网页
http://www.sctport.com.cn/newsctsite/kbindex.jspa?page=927693249094789198729781979723839289&id=28&pid=14
我在提单号框输入12082271,具体如图


点查询得到如下网页,请问这个网页如果抓取



------解决方案--------------------
你可以先在浏览器中操作,并且用http抓包软件拦截。

然后再在程序中依葫芦画瓢。
------解决方案--------------------
请求地址:http://www.sctport.com.cn/newsctsite/sct/resbillno.jsp
POST数据:billno=12082271&choice2=2&Submit2.x=25&Submit2.y=11
cookie:JSESSIONID=34EA96559B7FC7CD173F262C39B50E98(需要获取)

用HttpWebRequest发请求就可以了
------解决方案--------------------
用fiddler抓包,看下他的post请求
然后在程序里写个一样的就好了
------解决方案--------------------
可以看看Selenium。

firefox有插件,有.net API.
firefox插件录制的宏可以转换成C#代码。
------解决方案--------------------
C# code

//获取网页HTML
public static string GetHtml4Url(string url)
    {
        HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(url);
        req.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705;)";
        req.Method = "POST";
        req.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
        req.Headers.Add("Accept-Language: en-us,en-ru,en,ru;q=0.5");
        req.KeepAlive = true;
        req.Headers.Add("Keep-Alive: 300");
        req.Referer = url;
        req.ContentType = "application/x-www-form-urlencoded";
        HttpWebResponse response = (HttpWebResponse)req.GetResponse();
        StreamReader reader = new StreamReader(response.GetResponseStream(),Encoding.UTF8);
        string tmp = reader.ReadToEnd();
        reader.Close();
        return tmp;
    }

------解决方案--------------------
用抓包软件吧
------解决方案--------------------
已经给你答案了
探讨
发送HttpWebRequest获取HTML的方法:


C# code

public class HttpHelper
{
public static string contentType = "application/x-www-form-urlencoded";
public static string accept = "i……

------解决方案--------------------
http://download.csdn.net/detail/sy_dingzi/4658993
------解决方案--------------------
JSESSIONID 按字面解释 应该是java的 session的标识