这是java 语言的,有python的如果要的话在评论区要把,直接上代码~~
1 import java.io.BufferedReader; 2 import java.io.IOException; 3 import java.io.InputStream; 4 import java.io.InputStreamReader; 5 import java.io.OutputStreamWriter; 6 import java.net.URL; 7 import java.net.URLConnection; 8 9 public class seuCrawl { 10 11 public static void testPost() throws IOException { 12 13 //连接地址 14 String surl = "http://xk.urp.seu.edu.cn/jw_service/service/stuCurriculum.action"; 15 16 /** 17 * 首先要和URL下的URLConnection对话。 URLConnection可以很容易的从URL得到。比如: // Using 18 * java.net.URL and //java.net.URLConnection 19 */ 20 URL url = new URL(surl); 21 URLConnection connection = url.openConnection(); 22 23 /** 24 * 然后把连接设为输出模式。URLConnection通常作为输入来使用,比如下载一个Web页。 25 * 通过把URLConnection设为输出,你可以把数据向你个Web页传送。下面是如何做: 26 */ 27 connection.setDoOutput(true); 28 /** 29 * 最后,为了得到OutputStream,简单起见,把它约束在Writer并且放入POST信息中,例如: ... 30 */ 31 OutputStreamWriter out = new OutputStreamWriter(connection 32 .getOutputStream(), "UTF-8"); 33 String submitInfo = "queryStudentId="+"2131335"+"&"+"stuCurriculum_queryAcademicYear="+"14-15-2"; 34 out.write("queryStudentId=2131335&stuCurriculum_queryAcademicYear=14-15-2"); //post的关键所在! 35 // remember to clean up 36 out.flush(); 37 out.close(); 38 /** 39 * 这样就可以发送一个看起来象这样的POST: 40 * POST /jobsearch/jobsearch.cgi HTTP 1.0 ACCEPT: 41 * text/plain Content-type: application/x-www-form-urlencoded 42 * Content-length: 99 username=bob password=someword 43 */ 44 // 一旦发送成功,用以下方法就可以得到服务器的回应: 45 String sCurrentLine; 46 String sTotalString; 47 sCurrentLine = ""; 48 sTotalString = ""; 49 InputStream l_urlStream; 50 l_urlStream = connection.getInputStream(); 51 // 传说中的三层包装阿! 52 BufferedReader l_reader = new BufferedReader(new InputStreamReader( 53 l_urlStream)); 54 while ((sCurrentLine = l_reader.readLine()) != null) { 55 sTotalString += sCurrentLine + " "; 56 57 } 58 System.out.println(sTotalString); 59 } 60 61 public static void main(String[] args) throws IOException { 62 63 testPost(); 64 65 } 66 67 }