<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    迷失的風

    就這樣活著
    隨筆 - 1, 文章 - 1, 評論 - 1, 引用 - 0
    數據加載中……

    PostMethod獲取post提交的頁面代碼

    http://lsg.cnki.net/grid20/Brief.aspx?ID=1&classtype=&systemno=&NaviDatabaseName=&NaviField=

    這個是中國期刊網的檢索請求,我現在需要通過這個來獲取檢索出來的信息,解決方法已經有了,就是得不到檢索信息,查詢內容是空的。
    應該是少add了一些檢索所需內容。

    下面是我的代碼
     1import java.io.IOException; 
     2import java.util.Calendar; 
     3import java.util.GregorianCalendar; 
     4import org.apache.commons.httpclient.HttpClient; 
     5import org.apache.commons.httpclient.HttpException; 
     6import org.apache.commons.httpclient.HttpStatus; 
     7import org.apache.commons.httpclient.methods.PostMethod; 
     8
     9
    10public class PostTest 
    11
    12public static void main(String[] args)
    13
    14PostMethod postMethod = new PostMethod("http://lsg.cnki.net/grid20/Brief.aspx?ID=1&classtype=&systemno=&NaviDatabaseName=&NaviField="); 
    15postMethod.addParameter("advancedvalue1","java"); 
    16postMethod.addParameter("advancedfield1","主題"); 
    17postMethod.addParameter("yearstart","1979"); 
    18postMethod.addParameter("yearend",String.valueOf(GregorianCalendar.getInstance().get(Calendar.YEAR))); 
    19postMethod.addParameter("RecordsPerPage","20"); 
    20postMethod.addParameter("SearchRange","All"); 
    21postMethod.addParameter("searchmatch","0"); 
    22postMethod.addParameter("order","dec"); 
    23postMethod.addParameter("display","chinese"); 
    24postMethod.addParameter("NaviDatabaseName","ZJCLS"); 
    25postMethod.addParameter("encode","gb"); 
    26postMethod.addParameter("VarNum","1"); 
    27postMethod.addParameter("singleleafcode","J"); 
    28postMethod.addParameter("strNavigatorName",",A,B,C,D,E,F,G,H,I,J"); 
    29postMethod.addParameter("strNavigatorValue",",理工A(數學物理力學天地生),理工B(化學化工冶金環境礦業),理工C(機電航空交通水利建筑能源),農業,醫藥衛生,文史哲,政治軍事與法律,教育與社會科學綜合,電子技術及信息科學,經濟與管理"); 
    30HttpClient client = new HttpClient(); 
    31client.setConnectionTimeout(1000 * 60); 
    32int status=0
    33try 
    34status = client.executeMethod(postMethod); 
    35}
     catch (HttpException e) 
    36// TODO Auto-generated catch block 
    37e.printStackTrace(); 
    38}
     catch (IOException e) 
    39// TODO Auto-generated catch block 
    40e.printStackTrace(); 
    41}
     
    42if(status==HttpStatus.SC_OK) 
    43makeResponseObject(postMethod.getResponseBodyAsString()); 
    44}
     else 
    45}
     
    46postMethod.releaseConnection(); 
    47
    48}
     
    49// 根據HTTP請求后返回的字串生成結果封裝類的實例 
    50private static void makeResponseObject(String sResponse) 
    51System.out.println("-------------------"+sResponse); 
    52System.out.println("-------------------"); 
    53String regExNums = "<TD\\s*style=\"FONT-SIZE:\\s*9pt;\\s*COLOR:\\s*#000000;\\s*WORD-WRAP:\\s*break-word\"\\s*vAlign=center\\s*bgColor=#f4f5f6\\s*height=30>\\s*共有記錄\\s*(\\d+)\\s*條\\s* \\s*</TD>"
    54String regExData = "<TR>\\s*<TD\\s*style=\"FONT-SIZE:\\s*9pt;\\s*WORD-WRAP:\\s*break-word\"\\s*(?:align=left)?\\s*bgColor=#\\S+\\s*>([\\s\\S]*?)</TR>"
    55String regExPage = "<TD\\s*style=\"FONT-SIZE:\\s*9pt;\\s*COLOR:\\s*#000000;\\s*WORD-WRAP:\\s*break-word\"\\s*vAlign=center\\s*bgColor=#f4f5f6\\s*height=30>\\s*<A\\s*href=\"(.*)\">(?:上頁|下頁)</A>"
    56}
     
    57
    58}
     
    59

    哪位大哥幫幫忙,解決下

    posted on 2008-06-16 10:25 迷失的風 閱讀(3260) 評論(1)  編輯  收藏

    評論

    # re: PostMethod獲取post提交的頁面代碼[未登錄]  回復  更多評論   

    用NameValuePair[] data = { new NameValuePair("id", "youUserName"),new NameValuePair("passwd", "yourPwd") };這種方式傳參數試試,先確定你是不是post了所有必需的參數,然后再檢查獲取到的數據。
    2008-06-21 22:52 | Chris

    只有注冊用戶登錄后才能發表評論。


    網站導航:
     
    主站蜘蛛池模板: free哆啪啪免费永久| 久久精品成人免费看| 成人免费无码大片A毛片抽搐| 亚洲精品免费视频| 中文字幕免费人成乱码中国| AV在线亚洲男人的天堂| 四虎影视永久在线精品免费| 免费国产a国产片高清网站| 在线aⅴ亚洲中文字幕| 在线观看免费大黄网站| 亚洲国产一区二区三区在线观看| 午夜小视频免费观看| 麻豆亚洲AV成人无码久久精品 | 免费福利在线观看| 亚洲伊人久久综合中文成人网| 岛国岛国免费V片在线观看| 国产AV无码专区亚洲精品| 日本免费电影一区二区| 亚洲欧洲国产视频| 女人18毛片a级毛片免费 | 中国人免费观看高清在线观看二区| 亚洲中文字幕无码爆乳AV| 久久青草免费91观看| 亚洲成a人片毛片在线| 德国女人一级毛片免费| 精品亚洲国产成人av| 亚洲无人区一区二区三区| 五月亭亭免费高清在线| AV激情亚洲男人的天堂国语| 国产精品亚洲一区二区三区在线 | 成人性生交大片免费看好| 亚洲欧洲日本精品| 卡1卡2卡3卡4卡5免费视频| 一区在线免费观看| 久久综合亚洲色一区二区三区| 青草草在线视频永久免费| 一级做性色a爰片久久毛片免费| 亚洲成在人天堂一区二区| 国产色爽女小说免费看| 嫩草成人永久免费观看| 亚洲6080yy久久无码产自国产|