public Web ( String Query, String Options, String WebSearchOptions, String Market, String Adult, Double Latitude, Double Longitude, String WebFileType ) : DataServiceQuery |
||
Query | String | Bing search query Sample Values : xbox |
Options | String | Specifies options for this request for all Sources. Valid values are: DisableLocationDetection, EnableHighlighting. Sample Values : EnableHighlighting |
WebSearchOptions | String | Specify options for a request to the Web SourceType. Valid values are: DisableHostCollapsing, DisableQueryAlterations. Sample Values : DisableQueryAlterations |
Market | String | Market. Note: Not all Sources support all markets. Sample Values : en-US |
Adult | String | Adult setting is used for filtering sexually explicit content Sample Values : Moderate |
Latitude | Double | Latitude Sample Values : 47.603450 |
Longitude | Double | Longitude Sample Values : -122.329696 |
WebFileType | String | File extensions to return Sample Values : XLS |
Résultat | DataServiceQuery |
public static IEnumerable<WebResult> ResultSet() { string bingAccountKey = ConfigurationManager.AppSettings["BingKey"].ToString(); string address = ConfigurationManager.AppSettings["ApiUrl"].ToString(); var bing = new BingSearchContainer( new Uri(address)) { Credentials = new NetworkCredential(bingAccountKey, bingAccountKey) }; var query = bing.Web("xbox live", null, null, null, null, null, null, null); query = query.AddQueryOption("$top",100); var results = query.Execute(); return results; }
private void button1_Click_1(object sender, System.EventArgs e) { try { richTextBox1.Text = ""; const string apiKey = "AIzaSyDIm9ZOWD8Zd-2tHy5r3c0R-_XjdEFaXGE"; const string searchEngineId = "003470263288780838160:ty47piyybua"; string query1 = textBox1.Text; CustomsearchService customSearchService = new CustomsearchService(new Google.Apis.Services.BaseClientService.Initializer() { ApiKey = apiKey }); Google.Apis.Customsearch.v1.CseResource.ListRequest listRequest = customSearchService.Cse.List(query1); listRequest.Cx = searchEngineId; Search search = listRequest.Execute(); foreach (var item in search.Items) { richTextBox1.Text += item.Link; richTextBox1.Text += " \n "; } richTextBox1.Text += " \n ---------------------- \n "; Repeater rptResult = new Repeater(); string rootUrl = "https://api.datamarket.azure.com/Bing/Search"; string query = textBox1.Text; var bingContainer = new Bing.BingSearchContainer(new Uri(rootUrl)); string market = "en-us"; bingContainer.Credentials = new NetworkCredential("bucsexiyu8a87Nw1u3mmTJ/BCPAzGOKFQcydlXYn1S8", "bucsexiyu8a87Nw1u3mmTJ/BCPAzGOKFQcydlXYn1S8"); var webQuery = bingContainer.Web(query, null, null, null, null, null, null, null); webQuery = webQuery.AddQueryOption("$top", 10); var webResults = webQuery.Execute(); System.Windows.Forms.Label lblResults = new System.Windows.Forms.Label(); StringBuilder searchResult = new StringBuilder(); foreach (Bing.WebResult wResult in webResults) { richTextBox1.Text += wResult.Url; } }catch (Exception ex) { richTextBox1.Text = "404 Not Found"; } }
public void searchNewsByAddress(string address) { string rootUri = "https://api.datamarket.azure.com/Bing/Search"; var bingContainer = new BingSearchContainer(new Uri(rootUri)); string accountKey = App.Current.Resources["AzureAccountKey"] as string; bingContainer.UseDefaultCredentials = false; bingContainer.Credentials = new NetworkCredential(accountKey, accountKey); string searchTerm = address + " (site:hir24.hu OR site:origo.hu OR site:index.hu) -site:ingatlanapro.origo.hu -site:forum.index.hu -site:cimkezes.origo.hu -site:admin.index.hu"; /*Deployment.Current.Dispatcher.BeginInvoke(() => { MessageBox.Show(searchTerm); });*/ var newsQuery = bingContainer.Web(searchTerm, null, "DisableQueryAlterations", null, null, null, null, null); newsQuery.AddQueryOption("$top", 20); var result = newsQuery.BeginExecute(_onNewsQueryComplete, newsQuery); }
public List<BingResult> GetBingResult(string parameter) { //const string bingKey = "9F3eqLyfmNP0PInNOmS13FdSlPoajoJqLvrbvndqZFM"; const string bingKey = "wHln8JsLTWNIEDHZTxU3mTjnIr9T7HCGZPZ86BPYZKg"; var bing = new BingSearchContainer( new Uri("https://api.datamarket.azure.com/Bing/Search/")) { Credentials = new NetworkCredential(bingKey, bingKey) }; var query = bing.Web(parameter, null, null, "en-US", null, null, null, null); var results = query.Execute(); List<BingResult> binglist = new List<BingResult> (); foreach (var result in results) { BingResult bingResult = new BingResult (); bingResult.ID = result.ID; bingResult.Url = result.Url; bingResult.Description = result.Description; bingResult.DisplayUrl = result.DisplayUrl; bingResult.Title = result.Title; binglist.Add (bingResult); } return binglist; }
public string GetAdvice(string query) { var client = new BingSearchContainer(new Uri("https://api.datamarket.azure.com/Bing/searchweb/")); var market = "en-us"; //client.Credentials = new NetworkCredential("accountKey", "lwc+7icqRrPiLk03xLoYzZ7h75GGRPke1HchZpkpKYc"); client.Credentials = new NetworkCredential("lwc+7icqRrPiLk03xLoYzZ7h75GGRPke1HchZpkpKYc", "lwc+7icqRrPiLk03xLoYzZ7h75GGRPke1HchZpkpKYc"); //var marketData = client.Web(query, null, null, null, null, null, null, null).Execute(); //var marketData = client.Web(query, market, "Moderate", 47.603450, -122.329696, "XLX", "EnableHighlighting", "DisableQueryAlterrations").Execute(); try { var marketData = client.Web(query, market, "Moderate", null, null, null, null, null); marketData = marketData.AddQueryOption("$top", 10); // Run the query and display the results. var webResults = marketData.Execute(); //Label lblResults = new Label(); StringBuilder searchResult = new StringBuilder(); foreach (Bing.WebResult wResult in webResults) { searchResult.Append(string.Format("<a href={2}>{0}</a><br /> {1}<br /> {2}<br /><br />", wResult.Title, wResult.Url, wResult.Description)); } return searchResult.ToString(); } catch { return "Exception Occured"; } }
void BindResults() { if (queryText.Length == 0) { return; } hdnSHC.Value = queryText.GetHashCode().ToInvariantString(); //Linq2Bing bing = new Linq2Bing(bingApiId); //IQueryable<BaseResult> LinqExpression; //if (searchDomain.Length > 0) //{ // LinqExpression = // (from w in bing.Web // where w.Site == searchDomain && w.Text == queryText // select w).Skip(Offset).Take(pageSize); //} //else //{ // LinqExpression = // (from w in bing.Web // where w.Text == queryText // select w).Skip(Offset).Take(pageSize); //} #if !MONO BingSearchContainer bingContainer = new BingSearchContainer(new Uri(WebConfigSettings.BingApiUrl)); bingContainer.Credentials = new NetworkCredential(bingAccountKey, bingAccountKey); var webResults = bingContainer.Web("site:" + searchDomain + " " + queryText, null, null, null, null, null, null, pageSize, Offset); try { //resultCount = LinqExpression.Web().Count<BaseResult>(); //rptResults.DataSource = LinqExpression.Web(); rptResults.DataSource = webResults; rptResults.DataBind(); resultCount = rptResults.Items.Count; } catch (ArgumentNullException) { } //happens when there are no results // unfortunately I have not found a way to find the total number of search hits so // we can't use traditional paging but can only do next previous first type paging // since we don't know how many total pages there are btnNext.Visible = (resultCount >= pageSize); if (Offset < pageSize) { btnFirst.Visible = false; btnPrevious.Visible = false; } else { btnFirst.Visible = true; btnPrevious.Visible = true; } //if (resultCount > 0) //{ // rptResults.DataSource = LinqExpression.Web(); // rptResults.DataBind(); //} pnlNoResults.Visible = (resultCount == 0); #endif }