You do not need to enter the Baidu homepage every time, enter keywords, and then click search. Directly create a console program and open the search page.
Click here to download all source programs
Main source program:
[Csharp]
// Author: PJ
Using System;
Using System. Web;
Using System. Diagnostics;
Namespace QhCSharp {
Class Program {
Public static void Main (string [] args ){
If (args. Length = 0 ){
Process. Start ("http://www.baidu.com ");
} Else if (args. Length = 1 ){
Process. Start ("http://www.baidu.com/s? Wd = "+ args [0]);
} Else if (args. Length = 2 ){
String searchType = args [0]. ToLower ();
If (searchType = "news "){
Process. Start ("http://news.baidu.com/ns? Word = "+ HttpUtility. UrlEncode (args [1], System. Text. Encoding. GetEncoding (" GB2312 ")));
} Else if (searchType = "web "){
Process. Start ("http://www.baidu.com/s? Wd = "+ HttpUtility. UrlEncode (args [1], System. Text. Encoding. GetEncoding (" GB2312 ")));
} Else if (searchType = "mp3 "){
Process. Start ("http://mp3.baidu.com/m? Word = "+ HttpUtility. UrlEncode (args [1], System. Text. Encoding. GetEncoding (" GB2312 ")));
} Else if (searchType = "image "){
Process. Start ("http://image.baidu.com/I? Word = "+ HttpUtility. UrlEncode (args [1], System. Text. Encoding. GetEncoding (" GB2312 ")));
} Else if (searchType = "video "){
Process. Start ("http://video.baidu.com/v? Word = "+ HttpUtility. UrlEncode (args [1], System. Text. Encoding. GetEncoding (" GB2312 ")));
} Else if (searchType = "wenku "){
Process. Start ("http://wenku.baidu.com/search? Word = "+ HttpUtility. UrlEncode (args [1], System. Text. Encoding. GetEncoding (" GB2312 ")));
} Else {
Console. WriteLine ("Unknown search type .");
}
} Else {
Console. WriteLine ("Usage: Baidu <SearchType> <Keyword> ");
Console. WriteLine ("SearchType :");
Console. WriteLine ("\ tnews ");
Console. WriteLine ("\ tweb ");
Console. WriteLine ("\ tmp3 ");
Console. WriteLine ("\ timage ");
Console. WriteLine ("\ tvideo ");
Console. WriteLine ("\ twenku ");
}
}
}
}