更新时间:2023-12-06 14:26:40
使用Httpwebrequest对象及其选项,我已经解决了这个问题。感谢所有人。
With Httpwebrequest object and its options I`ve solved this problem. thanks of all.
StringBuilder sb = new StringBuilder();
// used on each read operation
byte[] buf = new byte[8192];
string GS = "http://google.com/search?q=";
// prepare the web page we will be asking for
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(GS);
// execute the request
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
// we will read data via the response stream
Stream resStream = response.GetResponseStream();
string tempString = null;
int count = 0;
do
{
// fill the buffer with data
count = resStream.Read(buf, 0, buf.Length);
// make sure we read some data
if (count != 0)
{
// translate from bytes to ASCII text
tempString = Encoding.ASCII.GetString(buf, 0, count);
// continue building the string
sb.Append(tempString);
}
}
while (count > 0);
如果我理解正确,以下链接可以帮助您:
http://kiwigis.blogspot.in/2011/03/google-custom -search-in-c.html [ ^ ]
http://www.eggheadcafe。 com / articles / 20020802.asp [ ^ ]
http:// blog.adamroderick.com/2009/11/google-search-api-with-c-and-json-net/ [ ^ ]
If I understand you correctly, the below links could help you:
http://kiwigis.blogspot.in/2011/03/google-custom-search-in-c.html[^]
http://www.eggheadcafe.com/articles/20020802.asp[^]
http://blog.adamroderick.com/2009/11/google-search-api-with-c-and-json-net/[^]