[Original] handy gadgets development-tools used to screen the number of applicants for my position in the Civil Servant Examination

Source: Internet
Author: User
[Open the engine]

It's also a year's Civil Servant Examination. I 've been struggling with whether or not I have to go to Muddy Waters again, and the other is going to go ashore. Registration started on January 1, March 1. The deadline is the last day. My attitude is to wait for a few days. In the final stages of May 6, I will select a position with relatively low competition pressure based on the registration situation. Because the examination will be released on a regular basis every day until XX has registered the number of people list, is this: http://gwybm.tjpnet.gov.cn/info/bmqk.htm too many jobs, it is too much trouble to find it. So I plan to write a small tool and select the number of registrants for the position based on my intention. This is all done once and for all ~~ (This is only valid six days ago ..)

[Development implementation]

1. Open Vs and create a simple winform interface.

Includes a button, a RichTextBox, and a webbrower control.

2. The content in RichTextBox can be read from a text file or directly input in the control. The format must be as follows:

Example: 208, Tanggu judgment area of the people's court, administrative comprehensive 2;

"208" is the unitCodeThe "Tanggu judicial district of the People's Court" is the applicant department, and "Administrative comprehensive 2" is the recruitment position. With these three elements, you can determine the position I want to wait! Oh, by the way, this job information is included in the XLS document of the Recruitment Form. After selecting this job, you can retrieve these three elements.

3. webbrower is used to display the filtered job information, which is actually a rewritten HTML code.

4. Compile button processing events

The source code is as follows:

        Private   Void Button#click ( Object Sender, eventargs E)
{


WebClient client = New WebClient ();
Stream mystream = client. openread ( @" Http://gwybm.tjpnet.gov.cn/info/bmqk.htm " ); // This is a list of positions for the current day
Streamreader sr =New Streamreader (mystream );
String Strhtml = Sr. readtoend (); // Get all source code
Sr. Close ();

// Start from the page header.
Int Headend = strhtml. indexof ( " <Tr class = \ "public_form_td \"> " );
String Strhead = strhtml. substring ( 0 , Headend ); // Obtains the header code of the Source Page to assemble the entire page.
// End with the page header

// Start with ranking table
Int Startindex = 0 ;
Int Stopindex = 0 ;
List < String > Liststr =New List < String > (); // <Tr> </tr> mark of all positions
For ( Int I = 0 ; I < 5000 ; I ++)
{
Startindex = strhtml. indexof ( " <Tr class = \ "public_form_td \"> " ) +27 ;

Stopindex = strhtml. indexof ( " </Tr> " , Startindex) + 5 ;
If (Startindex = 26 | Stopindex = 4 ) // If the string cannot be found, it indicates that all strings have been obtained and the loop has ended.
{
I =1000000 ;
Continue ;
}
String Item = " <Tr class = \ "public_form_td \"> " + Strhtml. substring (startindex, stopindex-startindex );
Liststr. Add (item );
Strhtml = strhtml. substring (stopindex );
}
// The position table is ended.

// Start to process information about the selected position
String Strmyfav = This . Richtextbox1.text;
String [] Myfav = strmyfav. Split ( ' ; ' );
For ( Int I = 0 ; I <myfav. length; I ++)
{
Myfav [I] = myfav [I]. Replace (' \ N ' , ' ' );
}
// Process the selected job information.

List < String > Myfaver = New List < String > (); // Save the <tr> </tr> tag set for the last position to be filtered.
Foreach ( String Singelfav In Myfav)
{
String [] Keyword = singelfav. Split ( ' , ' );
Foreach ( String Singlejob In Liststr)
{
Int Correctcount = 0 ;
For ( Int I = 0 ; I <keyword. length; I ++)
{

If (Singlejob. Contains (keyword [I]. Trim ())) // I spent more than an hour with a space.
{
Correctcount ++;
}

}
If (Correctcount = keyword. Length & keyword. length! = 1 ) // If the number of strings matches the number of elements for the selected position, this position is the position to be selected.
{
Myfaver. Add (singlejob );
}
}

}
// Re-assemble the HTML to be rendered
Stringbuilder mylisthtml =New Stringbuilder ();
Mylisthtml. appendline (strhead );
Foreach ( String Line In Myfaver)
{
Mylisthtml. appendline (line );
}
Mylisthtml. appendline ( " </Table> </TD> " );
Mylisthtml. appendline ( " </Tr> " );
Mylisthtml. appendline ( " </Table> </TD> " );
Mylisthtml. appendline ( " </Tr> " );
Mylisthtml. appendline ( " </Table> " );
Mylisthtml. appendline (" </Body> " );
Mylisthtml. appendline ( " </Html> " );
// Re-assemble the HTML to be rendered.
Webbrowser1.documenttext = mylisthtml. tostring ();


}

Private Void Form1_load (Object Sender, eventargs E)
{
Streamreader sr = New Streamreader (application. startuppath + @" \ Myfav.txt " );
This . Richtextbox1.text = Sr. readtoend ();
Sr. Close ();

}
[Tool demo]

 

[Summary]

This tool is mainly worth mentioning in the processing of strings, especially when a space is ignored during debugging, resulting in a waste of one hour...

 

Author: Tony Zhao

Source: http://www.cnblogs.com/ytaozhao this article copyright to the author and blog park a total, welcome to reprint, but without the author's consent must retain this paragraph of the statement, and inArticleThe original text connection is clearly displayed on the page. Otherwise, the legal liability is retained.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.