public static void Main(string[] args){
SearchGoogle("Test");
Console.ReadKey(true);
}
static void SearchGoogle(string t){
Process.Start("http://google.com/search?q=" + t);
}
Run Code Online (Sandbox Code Playgroud)
有没有办法隐藏浏览器,所以它不会弹出?
小智 11
就像是:
ProcessStartInfo startInfo = new ProcessStartInfo("http://google.com/search?q=" + t);
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
Process.Start(startInfo);
Run Code Online (Sandbox Code Playgroud)
如果您想要结果而不是浏览器,则可以使用WebClient类.
using (var client = new WebClient())
{
string html = client.DownloadString("http://google.com/search?q=" + "Test");
}
Run Code Online (Sandbox Code Playgroud)