bing

package module
v0.0.0-...-da33012 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 9, 2018 License: MIT Imports: 5 Imported by: 0

README

go-bing

Golang Library for bing search API v7

Before getting started with this lib you need to get a Bing Search Token

go-bin is written with simplicity in mind

Installation

go get -v github.com/Nhoya/go-bing

Usage

package main

import (
        "fmt"
        "github.com/Nhoya/go-bing"
)

func main() {
        //Create new Client instance
        client := bing.NewClient("INSERT TOKEN HERE")
        //Start searching
        resp, err := client.Search("Nhoya gOSINT")
        if err != nil {
                panic(err)
        }
        //Iterate over search results
        for _, result := range resp.WebPages.Value {
            //Printing result name and URL    
            fmt.Println(result.Name, "||", result.URL)
        }
}

//Output:
//GitHub - Nhoya/gOSINT: OSINT framework in Go || https://github.com/Nhoya/gOSINT
//Refactoring lots of stuff · Nhoya/gOSINT@2bb5d91 · GitHub || https://github.com/Nhoya/gOSINT/commit/2bb5d913da7c3ad4636cfc02c719e347a6c2fc2e
//gOSINT - Open Source Intelligence Framework - KitPloit ... || https://www.kitploit.com/2018/01/gosint-open-source-intelligence.html
//gOSINT – Open Source Threat Intelligence Gathering ... || https://pentesttoolz.com/2018/01/22/gosint-open-source-threat-intelligence-gathering-processing-framework-2/
//...

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BingAnswer

type BingAnswer struct {
	Type         string `json:"_type"`
	QueryContext struct {
		OriginalQuery string `json:"originalQuery"`
	} `json:"queryContext"`
	WebPages struct {
		WebSearchURL          string `json:"webSearchUrl"`
		TotalEstimatedMatches int    `json:"totalEstimatedMatches"`
		Value                 []struct {
			ID               string    `json:"id"`
			Name             string    `json:"name"`
			URL              string    `json:"url"`
			IsFamilyFriendly bool      `json:"isFamilyFriendly"`
			DisplayURL       string    `json:"displayUrl"`
			Snippet          string    `json:"snippet"`
			DateLastCrawled  time.Time `json:"dateLastCrawled"`
			SearchTags       []struct {
				Name    string `json:"name"`
				Content string `json:"content"`
			} `json:"searchTags,omitempty"`
			About []struct {
				Name string `json:"name"`
			} `json:"about,omitempty"`
		} `json:"value"`
	} `json:"webPages"`
	RelatedSearches struct {
		ID    string `json:"id"`
		Value []struct {
			Text         string `json:"text"`
			DisplayText  string `json:"displayText"`
			WebSearchURL string `json:"webSearchUrl"`
		} `json:"value"`
	} `json:"relatedSearches"`
	RankingResponse struct {
		Mainline struct {
			Items []struct {
				AnswerType  string `json:"answerType"`
				ResultIndex int    `json:"resultIndex"`
				Value       struct {
					ID string `json:"id"`
				} `json:"value"`
			} `json:"items"`
		} `json:"mainline"`
		Sidebar struct {
			Items []struct {
				AnswerType string `json:"answerType"`
				Value      struct {
					ID string `json:"id"`
				} `json:"value"`
			} `json:"items"`
		} `json:"sidebar"`
	} `json:"rankingResponse"`
}

type BingError

type BingError struct {
	StatusCode int    `json:"statusCode"`
	Message    string `json:"message"`
}

type Client

type Client struct {
	Token  string
	Client http.Client
}

func NewClient

func NewClient(token string) *Client

NewClient creates a new bing client istance

func (*Client) Search

func (c *Client) Search(search string) (*BingAnswer, error)

Simple Bing Search function

type Query

type Query struct {
	//The number of answers that you want the response to include. The answers that Bing returns are based on ranking. For example, if Bing returns webpages, images, videos, and relatedSearches for a request and you set this parameter to two (2), the response includes webpages and images.
	AnswerCount int
	//Country code for answer
	CC string
	//Number of search result
	Count int16
	//Filter seach results by ages values (Day, Week, Month)
	Freshness string
	//Country of the request sender
	Mkt string
	//Number of search results to skip
	Offset  int16
	Promote string
	//The actual research query
	Q string
	//A comma-delimited list of answers to include in the response (Computation, Entities, Images, News, RelatedSearches, SpellSuggestions, TimeZone, Videos, Webpages)
	ResponseFilter string
	//Off, Moderate Strict
	SafeSearch string
	//default languages for the interface
	SetLang string
	//active/deactive text Decoration
	TextDecoration bool
}

func NewQuery

func NewQuery(query string) *Query

Create a standart Query Object

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL