Private activity case 3: small tools for getting scores of ordinary high school admission from a website in a city 0 Preface
As we get older, our memory is getting worse and worse. We just want to record some of our scattered private experiences. We can look back later and remember these small projects and technical points, we can also think of the past that deals with customers and friends.
I personally like to be practical and do not like to do research. This private cases series are all small tools, small applications, no advanced technology and complex processes. I always believe that the technology that can be applied to actual projects is a good technology.
Without making money, you can learn a lot about technology, but you are not proficient in it.
Without talking about society, the reality is that we can see the truth, but do not learn the bad.
1 Background
WITKEY was a new term in a few years ago, so WITKEY is also very popular in China. Once upon a time, I also moved on to the major Chinese weike.com, where I was a time-honored Weike. At that time, I had known many colleagues, many customers, small projects, and small profits. This small tool is a private activity case taken over by weike.com, which should be the largest in China.
2 Requirement
A task released by a high school teacher. The requirements are described as follows: He wants to query the admission ticket number of more than 200 students (including Admission Ticket number, name, and admission score) from the website http://www.cczsb.com/zklq_2010.asp, however, it is very slow and time-consuming to manually query the website and copy it again. He wants to make a small tool. Based on his admission ticket information, he can automatically obtain the information and save it as a TXT text.
The manual query process is as follows:
1) Open the webpage and enter the admission ticket number to be queried:
2) Click the submit query content button to query the information:
3) manually copy the queried information to the TXT text:
3 Progress
After this activity, the first reflection was the webbrowser control, so we started to work in vs2005 and C #. (at that time, we just learned C #, and we took this opportunity to train our hands ), as I have done webbrowser development under VC before, I am very skilled and will soon finish writing.
4 Houyi
At that time, there was an episode, that was, I soon finished writing it, but I couldn't immediately tell him that I had finished taking the money, or people would think that such a simple thing would require so much money, so it took three days to deliver the service.ProgramWhat do you do, sometimes it's still a bit eye-catching ). At that time, I delivered a small tool. When I tested OK, the teacher was very happy and vivid.
5 Thoughts
This is a little tool. To tell the truth, there is really no technical content. But for non-professionals who do not know anything about it, It is very unpredictable. Sometimes programmers must be good at using this advantage to create maximum value.
6 Case
:
PS: the source code is really very simple. I am sorry to upload it. I 'd like to paste the key points.CodeI want to leave an email address for the source code and send it to me (Don't scold me. To be honest, I want to swear when I read the code at the time ).
View code
Private Void Webbrowser1_documentcompleted ( Object Sender, webbrowserdocumentcompletedeventargs e ){ This . Button1.enabled =True ; This . Textbox1.enabled = True ; This . Textbox2.enabled = True ; If (! Bflag) This . Lbmsg. Text = "" ; // This. webbrowser1.document. Window. scrollto (500,280 ); If (Iflag ){ String Shtml = "" ; Shtml = This . Webbrowser1.document. Body. innerhtml; shtml = Shtml. Replace ( " " , "" ); Shtml = Shtml. Replace ( " \ T " , "" ); Shtml = Shtml. Replace ( " \ R \ n " , "" ); // Get Admission Ticket No. String Snumbertagbegin = " <Fontsize = 4 face => Admission Ticket No. </font> </TD> <fontsize = 4 face => " ; Int Inumber = Shtml. indexof (snumbertagbegin ); String Snumbertemp = "" ; Snumbertemp = Shtml. substring (inumber + snumbertagbegin. length, 50 ); String Snumbertagend = " </Font> </TD> </tr> <tr> " ; Int Jnumber = 0 ; Jnumber = Snumbertemp. indexof (snumbertagend ); String Snumber = "" ; Snumber = Snumbertemp. substring ( 0 , Jnumber ); // Get name // Marker before name String Snametagbegin = " <Fontsize = 4 face => name </font> </TD> <fontsize = 4 face => " ; Int INAME = shtml. indexof (snametagbegin ); // Start position of the front part of the name String Snametemp = "" ; Snametemp = Shtml. substring (INAME + snametagbegin. length,50 ); // The first part of the name indicates the end position and the last 50 characters String Snametagend = " </Font> </TD> </tr> <tr> " ; // Partial name Mark Int Jname = 0 ; Jname = Snametemp. indexof (snametagend ); // Start position of the marker after name String Sname = "" ; Sname = Snametemp. substring ( 0 , Jname ); // Name // Admission score // Marker before score String Scounttagbegin = " <Fontsize = 4 face => admission score </font> </TD> <fontsize = 4 face => " ; Int Icount = Shtml. indexof (scounttagbegin ); String Scounttemp = "" ; Scounttemp = Shtml. substring (icount + scounttagbegin. length, 50 ); String Scounttagend = " </Font> </TD> </tr> <tr> " ; Int Jcount = 0 ; Jcount = Scounttemp. indexof (scounttagend ); String Scount = "" ; Scount = Scounttemp. substring ( 0 , Jcount ); String Sresult = "" ; Sresult =" Admission Ticket No: " + Snumber + " \ T " + " Name: " + Sname + " \ T " + " Admission score: " + Scount; iflag =False ; Loading = False ; // MessageBox. Show (sresult ); String Spath = system. Io. Directory. getcurrentdirectory () + " /Kskh.txt " ; Sresult = Sresult + " \ R \ n " ; This . Lbmsg. Text = " The program is being queried. Please wait ...... " ; This . Button1.enabled = False ; This . Textbox1.enabled = False ; This . Textbox2.enabled = False ; Makefile (Spath, sresult); itotal -- ; If (Itotal = 0 ){ This . Lbmsg. Text = " Query successful !!! " ; This . Button1.enabled = True ; This . Textbox1.enabled = True ; This . Textbox2.enabled = True ; MessageBox. Show ( " Query successful !!! " );}}}