Last active
October 1, 2018 07:15
-
-
Save nilsmagnus/5d287f082ef33a50ff858228df23f6bd to your computer and use it in GitHub Desktop.
algolia oslo ankomst heineman
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"encoding/json" | |
"fmt" | |
"io/ioutil" | |
"net/http" | |
"strings" | |
) | |
func main() { | |
body := strings.NewReader(`{"requests":[{"indexName":"products","params":"query=&hitsPerPage=800&maxValuesPerFacet=100&page=0&facets=%5B%22availableInFormatted%22%2C%22brand.name%22%2C%22manufacturer.name%22%2C%22country.name%22%2C%22cultivationArea.name%22%2C%22price.value%22%2C%22price.hasDiscount%22%2C%22categoryPathHierarchy.lvl0%22%2C%22categoryPathHierarchy.lvl1%22%5D&tagFilters=&facetFilters=%5B%22availableInFormatted%3A5111%22%2C%5B%22categoryPathHierarchy.lvl0%3ASprit%22%5D%5D"},{"indexName":"products","params":"query=&hitsPerPage=1&maxValuesPerFacet=100&page=0&attributesToRetrieve=%5B%5D&attributesToHighlight=%5B%5D&attributesToSnippet=%5B%5D&tagFilters=&facets=%5B%22categoryPathHierarchy.lvl0%22%5D&facetFilters=%5B%22availableInFormatted%3A5111%22%5D"}]}`) | |
req, err := http.NewRequest("POST", "https://namx6ho175-dsn.algolia.net/1/indexes/*/queries?x-algolia-agent=Algolia%20for%20vanilla%20JavaScript%20(lite)%203.21.1%3Binstantsearch.js%201.11.15%3BJS%20Helper%202.19.0&x-algolia-application-id=NAMX6HO175&x-algolia-api-key=3adaef81fcba8bf1d7a496ced40a3fe6", body) | |
if err != nil { | |
// handle err | |
} | |
req.Header.Set("Accept", "application/json") | |
req.Header.Set("Referer", "https://www.tax-free.no/5111/produkter/sprit/?s&hPP=800&idx=products&fR%5BavailableInFormatted%5D%5B0%5D=5111&hFR%5BcategoryPathHierarchy.lvl0%5D%5B0%5D=Sprit&is_v=1") | |
req.Header.Set("Origin", "https://www.tax-free.no") | |
req.Header.Set("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36") | |
req.Header.Set("Content-Type", "application/x-www-form-urlencoded") | |
resp, err := http.DefaultClient.Do(req) | |
defer resp.Body.Close() | |
if err != nil { | |
panic(err) | |
} | |
data, _ := ioutil.ReadAll(resp.Body) | |
structuredData := HeineManData{} | |
json.Unmarshal(data, &structuredData) | |
for _, r := range structuredData.Results{ | |
for _, h := range r.Hits{ | |
fmt.Println(h.Name) | |
} | |
} | |
} | |
type HeineManData struct { | |
Results []struct { | |
Hits []struct { | |
Code string `json:"code"` | |
Name string `json:"name"` | |
Size interface{} `json:"size"` | |
Colour interface{} `json:"colour"` | |
ColourDescription interface{} `json:"colourDescription"` | |
BaseProduct interface{} `json:"baseProduct"` | |
Images struct { | |
Small string `json:"small"` | |
Xsmall string `json:"xsmall"` | |
Large string `json:"large"` | |
Xlarge string `json:"xlarge"` | |
Medium string `json:"medium"` | |
} `json:"images"` | |
AvailableForCurrentStore interface{} `json:"availableForCurrentStore"` | |
DetailedPicture interface{} `json:"detailedPicture"` | |
Campaign interface{} `json:"campaign"` | |
Price struct { | |
Value int `json:"value"` | |
Currency struct { | |
Code string `json:"code"` | |
Name string `json:"name"` | |
} `json:"currency"` | |
BasicPrice interface{} `json:"basicPrice"` | |
HasDiscount bool `json:"hasDiscount"` | |
} `json:"price"` | |
CategoryPath []struct { | |
Code string `json:"code"` | |
Name string `json:"name"` | |
Path interface{} `json:"path"` | |
Subcategories interface{} `json:"subcategories"` | |
} `json:"categoryPath"` | |
Description string `json:"description"` | |
Country interface{} `json:"country"` | |
Brand struct { | |
Code string `json:"code"` | |
Name string `json:"name"` | |
URL string `json:"url"` | |
RelativeURL string `json:"relativeUrl"` | |
} `json:"brand"` | |
Unit struct { | |
Code string `json:"code"` | |
} `json:"unit"` | |
ErpProductName string `json:"erpProductName"` | |
MarketingText string `json:"marketingText"` | |
HasVariants bool `json:"hasVariants"` | |
VariantType interface{} `json:"variantType"` | |
Variants interface{} `json:"variants"` | |
ProducerNumber interface{} `json:"producerNumber"` | |
Polarized interface{} `json:"polarized"` | |
Age interface{} `json:"age"` | |
Material interface{} `json:"material"` | |
AlcoholByVolume int `json:"alcoholByVolume"` | |
Characteristics interface{} `json:"characteristics"` | |
ErpCharacteristics string `json:"erpCharacteristics"` | |
ServingSuggestions interface{} `json:"servingSuggestions"` | |
Year interface{} `json:"year"` | |
RawMaterials interface{} `json:"rawMaterials"` | |
Ingredients interface{} `json:"ingredients"` | |
Sex interface{} `json:"sex"` | |
MaterialOfFashion interface{} `json:"materialOfFashion"` | |
WineType interface{} `json:"wineType"` | |
Grapes interface{} `json:"grapes"` | |
CultivationArea interface{} `json:"cultivationArea"` | |
BeerType interface{} `json:"beerType"` | |
LiquorType struct { | |
Code string `json:"code"` | |
Name string `json:"name"` | |
} `json:"liquorType"` | |
TobaccoType interface{} `json:"tobaccoType"` | |
AppearanceSaturation struct { | |
Code string `json:"code"` | |
Name string `json:"name"` | |
} `json:"appearanceSaturation"` | |
ScentIntensity struct { | |
Code string `json:"code"` | |
Name string `json:"name"` | |
} `json:"scentIntensity"` | |
TasteFill struct { | |
Code string `json:"code"` | |
Name string `json:"name"` | |
} `json:"tasteFill"` | |
TasteIntensity struct { | |
Code string `json:"code"` | |
Name string `json:"name"` | |
} `json:"tasteIntensity"` | |
TasteTheAcid interface{} `json:"tasteTheAcid"` | |
Tannin interface{} `json:"tannin"` | |
Finish interface{} `json:"finish"` | |
Sweetness interface{} `json:"sweetness"` | |
TasteSweetness interface{} `json:"tasteSweetness"` | |
AlcoholTaste struct { | |
Code string `json:"code"` | |
Name string `json:"name"` | |
} `json:"alcoholTaste"` | |
Aftertaste struct { | |
Code string `json:"code"` | |
Name string `json:"name"` | |
} `json:"aftertaste"` | |
Served []struct { | |
Code string `json:"code"` | |
Name string `json:"name"` | |
} `json:"served"` | |
FitsFor []interface{} `json:"fitsFor"` | |
SuitableFor interface{} `json:"suitableFor"` | |
BagInBox interface{} `json:"bagInBox"` | |
Organic string `json:"organic"` | |
EdpEdt interface{} `json:"edpEdt"` | |
Aroma string `json:"aroma"` | |
Storage interface{} `json:"storage"` | |
SuggarContent interface{} `json:"suggarContent"` | |
OpprinnelsesLand interface{} `json:"opprinnelsesLand"` | |
BasicContent string `json:"basicContent"` | |
BasicContentUnit struct { | |
Code string `json:"code"` | |
Name string `json:"name"` | |
} `json:"basicContentUnit"` | |
TravelRetailExclusive interface{} `json:"travelRetailExclusive"` | |
FragranceNotes interface{} `json:"fragranceNotes"` | |
NotesPc interface{} `json:"notesPc"` | |
FragranceFamily interface{} `json:"fragranceFamily"` | |
ProductReferences []interface{} `json:"productReferences"` | |
CigarType interface{} `json:"cigarType"` | |
RingDimensions interface{} `json:"ringDimensions"` | |
RingDimensionsMm interface{} `json:"ringDimensionsMm"` | |
PostBox interface{} `json:"postBox"` | |
FlipOver interface{} `json:"flipOver"` | |
CoverSheet interface{} `json:"coverSheet"` | |
NumberOfCigars interface{} `json:"numberOfCigars"` | |
GramsCountPerCigar interface{} `json:"gramsCountPerCigar"` | |
TotalGramsCount interface{} `json:"totalGramsCount"` | |
TobaccoStrength interface{} `json:"tobaccoStrength"` | |
ProductNumber interface{} `json:"productNumber"` | |
MakeUpType interface{} `json:"makeUpType"` | |
ProductLine interface{} `json:"productLine"` | |
SkinCareType interface{} `json:"skinCareType"` | |
AppearanceClarity interface{} `json:"appearanceClarity"` | |
Bubbles interface{} `json:"bubbles"` | |
Foam interface{} `json:"foam"` | |
TasteFreshness interface{} `json:"tasteFreshness"` | |
TasteBitterness interface{} `json:"tasteBitterness"` | |
GlutenFree interface{} `json:"glutenFree"` | |
Packaging interface{} `json:"packaging"` | |
Spf interface{} `json:"spf"` | |
FoundationCoverage interface{} `json:"foundationCoverage"` | |
LipCoverage interface{} `json:"lipCoverage"` | |
ConcealerCoverage interface{} `json:"concealerCoverage"` | |
LipFinish interface{} `json:"lipFinish"` | |
PowderUse interface{} `json:"powderUse"` | |
Waterproof interface{} `json:"waterproof"` | |
ColuredSkincare interface{} `json:"coluredSkincare"` | |
AgeRange interface{} `json:"ageRange"` | |
OrganicNaturalSvanemerket interface{} `json:"organicNaturalSvanemerket"` | |
FaceCream interface{} `json:"faceCream"` | |
SalesAmount int `json:"salesAmount"` | |
Ean string `json:"ean"` | |
CategoryPathHierarchy struct { | |
Lvl0 string `json:"lvl0"` | |
Lvl1 string `json:"lvl1"` | |
Lvl2 string `json:"lvl2"` | |
} `json:"categoryPathHierarchy"` | |
AvailableInFormatted []string `json:"availableInFormatted"` | |
ObjectID string `json:"objectID"` | |
HighlightResult struct { | |
Code struct { | |
Value string `json:"value"` | |
MatchLevel string `json:"matchLevel"` | |
MatchedWords []interface{} `json:"matchedWords"` | |
} `json:"code"` | |
Name struct { | |
Value string `json:"value"` | |
MatchLevel string `json:"matchLevel"` | |
MatchedWords []interface{} `json:"matchedWords"` | |
} `json:"name"` | |
CategoryPath []struct { | |
Name struct { | |
Value string `json:"value"` | |
MatchLevel string `json:"matchLevel"` | |
MatchedWords []interface{} `json:"matchedWords"` | |
} `json:"name"` | |
} `json:"categoryPath"` | |
Description struct { | |
Value string `json:"value"` | |
MatchLevel string `json:"matchLevel"` | |
MatchedWords []interface{} `json:"matchedWords"` | |
} `json:"description"` | |
Brand struct { | |
Name struct { | |
Value string `json:"value"` | |
MatchLevel string `json:"matchLevel"` | |
MatchedWords []interface{} `json:"matchedWords"` | |
} `json:"name"` | |
} `json:"brand"` | |
} `json:"_highlightResult"` | |
} `json:"hits"` | |
NbHits int `json:"nbHits"` | |
Page int `json:"page"` | |
NbPages int `json:"nbPages"` | |
HitsPerPage int `json:"hitsPerPage"` | |
ProcessingTimeMS int `json:"processingTimeMS"` | |
Facets struct { | |
BrandName struct { | |
Bacardi int `json:"Bacardi"` | |
Braastad int `json:"Braastad"` | |
BacheGabrielsen int `json:"Bache-Gabrielsen"` | |
Jameson int `json:"Jameson"` | |
Absolut int `json:"Absolut"` | |
Koskenkorva int `json:"Koskenkorva"` | |
JackDanielS int `json:"Jack Daniel's"` | |
Larsen int `json:"Larsen"` | |
Jura int `json:"Jura"` | |
Lysholm int `json:"Lysholm"` | |
Vikingfjord int `json:"Vikingfjord"` | |
LIten int `json:"Løiten"` | |
Egge int `json:"Egge"` | |
GrahamS int `json:"Graham's"` | |
HighlandPark int `json:"Highland Park"` | |
TheFamousGrouse int `json:"The Famous Grouse"` | |
Bushmills int `json:"Bushmills"` | |
Gilde int `json:"Gilde"` | |
Glenfiddich int `json:"Glenfiddich"` | |
Hennessy int `json:"Hennessy"` | |
JimBeam int `json:"Jim Beam"` | |
JGermeister int `json:"Jägermeister"` | |
Kurayoshi int `json:"Kurayoshi"` | |
Nikka int `json:"Nikka"` | |
Stroh int `json:"Stroh"` | |
SureFisk int `json:"Sure Fisk"` | |
Aalborg int `json:"Aalborg"` | |
BallantineS int `json:"Ballantine's"` | |
Bombay int `json:"Bombay"` | |
Boulard int `json:"Boulard"` | |
Chivas int `json:"Chivas"` | |
Courvoisier int `json:"Courvoisier"` | |
GammelOpland int `json:"Gammel Opland"` | |
GreyGoose int `json:"Grey Goose"` | |
HavanaClub int `json:"Havana Club"` | |
JohnnieWalker int `json:"Johnnie Walker"` | |
MountGay int `json:"Mount Gay"` | |
OPAnderson int `json:"O.P. Anderson"` | |
Renault int `json:"Renault"` | |
RMyMartin int `json:"Rémy Martin"` | |
Shoot int `json:"Shoot"` | |
Soerlie int `json:"Soerlie"` | |
Stolichnaya int `json:"Stolichnaya"` | |
TheGlenlivet int `json:"The Glenlivet"` | |
Amarula int `json:"Amarula"` | |
AppletonRum int `json:"Appleton Rum"` | |
Asbach int `json:"Asbach"` | |
Baileys int `json:"Baileys"` | |
BaronOtard int `json:"Baron Otard"` | |
Bowmore int `json:"Bowmore"` | |
Bruichladdich int `json:"Bruichladdich"` | |
Bunnahabhain int `json:"Bunnahabhain"` | |
Camus int `json:"Camus"` | |
Cointreau int `json:"Cointreau"` | |
DewarS int `json:"Dewar's"` | |
DooleyS int `json:"Dooley's"` | |
FernetBranca int `json:"Fernet Branca"` | |
Fisherstorm int `json:"Fisherstorm"` | |
FlorDeCaA int `json:"Flor de Caña"` | |
GammelDansk int `json:"Gammel Dansk"` | |
GlenGrant int `json:"Glen Grant"` | |
Glenmorangie int `json:"Glenmorangie"` | |
Godet int `json:"Godet"` | |
Lapponia int `json:"Lapponia"` | |
Macallan int `json:"Macallan"` | |
Matusalem int `json:"Matusalem"` | |
PereMagloire int `json:"Pere Magloire"` | |
RussianStandard int `json:"Russian Standard"` | |
Speyburn int `json:"Speyburn"` | |
StRemy int `json:"St. Remy"` | |
TullamoreDew int `json:"Tullamore Dew"` | |
Underberg int `json:"Underberg"` | |
Valhalla int `json:"Valhalla"` | |
OneEnkelt int `json:"1-Enkelt"` | |
Alize int `json:"Alize"` | |
Amundsen int `json:"Amundsen"` | |
Aperol int `json:"Aperol"` | |
ArvesLvet int `json:"Arvesølvet"` | |
Beefeater int `json:"Beefeater"` | |
Beluga int `json:"Beluga"` | |
BenRiach int `json:"BenRiach"` | |
BisquitDubouche int `json:"Bisquit Dubouche"` | |
Botanist int `json:"Botanist"` | |
Campari int `json:"Campari"` | |
Chymos int `json:"Chymos"` | |
CockburnS int `json:"Cockburn's"` | |
Dalmore int `json:"Dalmore"` | |
Danzka int `json:"Danzka"` | |
Drambuie int `json:"Drambuie"` | |
FeeneyS int `json:"Feeney's"` | |
FernandoDeCastilla int `json:"Fernando de Castilla"` | |
Fireball int `json:"Fireball"` | |
Florio int `json:"Florio"` | |
GlenDeveron int `json:"Glen Deveron"` | |
GrantS int `json:"Grant's"` | |
Harahorn int `json:"Harahorn"` | |
HotNSweet int `json:"Hot n'Sweet"` | |
Janneau int `json:"Janneau"` | |
Kah int `json:"Kah"` | |
Kahlua int `json:"Kahlua"` | |
} `json:"brand.name"` | |
PriceValue struct { | |
Num29 int `json:"29"` | |
Num35 int `json:"35"` | |
Num36 int `json:"36"` | |
Num45 int `json:"45"` | |
Num49 int `json:"49"` | |
Num57 int `json:"57"` | |
Num69 int `json:"69"` | |
Num79 int `json:"79"` | |
Num85 int `json:"85"` | |
Num89 int `json:"89"` | |
Num95 int `json:"95"` | |
Num99 int `json:"99"` | |
Num105 int `json:"105"` | |
Num109 int `json:"109"` | |
Num119 int `json:"119"` | |
Num125 int `json:"125"` | |
Num129 int `json:"129"` | |
Num139 int `json:"139"` | |
Num145 int `json:"145"` | |
Num149 int `json:"149"` | |
Num155 int `json:"155"` | |
Num159 int `json:"159"` | |
Num165 int `json:"165"` | |
Num169 int `json:"169"` | |
Num175 int `json:"175"` | |
Num179 int `json:"179"` | |
Num189 int `json:"189"` | |
Num195 int `json:"195"` | |
Num199 int `json:"199"` | |
Num209 int `json:"209"` | |
Num215 int `json:"215"` | |
Num219 int `json:"219"` | |
Num229 int `json:"229"` | |
Num235 int `json:"235"` | |
Num239 int `json:"239"` | |
Num249 int `json:"249"` | |
Num259 int `json:"259"` | |
Num265 int `json:"265"` | |
Num269 int `json:"269"` | |
Num275 int `json:"275"` | |
Num279 int `json:"279"` | |
Num289 int `json:"289"` | |
Num299 int `json:"299"` | |
Num305 int `json:"305"` | |
Num309 int `json:"309"` | |
Num315 int `json:"315"` | |
Num319 int `json:"319"` | |
Num329 int `json:"329"` | |
Num339 int `json:"339"` | |
Num349 int `json:"349"` | |
Num359 int `json:"359"` | |
Num365 int `json:"365"` | |
Num369 int `json:"369"` | |
Num375 int `json:"375"` | |
Num379 int `json:"379"` | |
Num389 int `json:"389"` | |
Num399 int `json:"399"` | |
Num419 int `json:"419"` | |
Num429 int `json:"429"` | |
Num449 int `json:"449"` | |
Num469 int `json:"469"` | |
Num479 int `json:"479"` | |
Num499 int `json:"499"` | |
Num519 int `json:"519"` | |
Num549 int `json:"549"` | |
Num569 int `json:"569"` | |
Num599 int `json:"599"` | |
Num619 int `json:"619"` | |
Num625 int `json:"625"` | |
Num649 int `json:"649"` | |
Num669 int `json:"669"` | |
Num699 int `json:"699"` | |
Num719 int `json:"719"` | |
Num749 int `json:"749"` | |
Num769 int `json:"769"` | |
Num799 int `json:"799"` | |
Num819 int `json:"819"` | |
Num839 int `json:"839"` | |
Num849 int `json:"849"` | |
Num869 int `json:"869"` | |
Num899 int `json:"899"` | |
Num919 int `json:"919"` | |
Num949 int `json:"949"` | |
Num999 int `json:"999"` | |
Num1049 int `json:"1049"` | |
Num1099 int `json:"1099"` | |
Num1349 int `json:"1349"` | |
Num1449 int `json:"1449"` | |
Num1499 int `json:"1499"` | |
Num1549 int `json:"1549"` | |
Num1599 int `json:"1599"` | |
Num1649 int `json:"1649"` | |
Num1699 int `json:"1699"` | |
Num1799 int `json:"1799"` | |
Num2249 int `json:"2249"` | |
Num2999 int `json:"2999"` | |
Num3249 int `json:"3249"` | |
Num3999 int `json:"3999"` | |
Num14499 int `json:"14499"` | |
} `json:"price.value"` | |
ManufacturerName struct { | |
Martini int `json:"Martini"` | |
Bottega int `json:"Bottega"` | |
Allesverloren int `json:"Allesverloren"` | |
Torres int `json:"Torres"` | |
} `json:"manufacturer.name"` | |
PriceHasDiscount struct { | |
False int `json:"false"` | |
} `json:"price.hasDiscount"` | |
AvailableInFormatted struct { | |
Num5110 int `json:"5110"` | |
Num5111 int `json:"5111"` | |
Num5125 int `json:"5125"` | |
Num5135 int `json:"5135"` | |
Num5136 int `json:"5136"` | |
Num5145 int `json:"5145"` | |
Num5148 int `json:"5148"` | |
Num5155 int `json:"5155"` | |
Num5156 int `json:"5156"` | |
} `json:"availableInFormatted"` | |
CategoryPathHierarchyLvl0 struct { | |
Sprit int `json:"Sprit"` | |
} `json:"categoryPathHierarchy.lvl0"` | |
CategoryPathHierarchyLvl1 struct { | |
SpritWhisky int `json:"Sprit > Whisky"` | |
SpritLikR int `json:"Sprit > Likør"` | |
SpritCognac int `json:"Sprit > Cognac"` | |
SpritVodka int `json:"Sprit > Vodka"` | |
SpritAkevitt int `json:"Sprit > Akevitt"` | |
SpritRom int `json:"Sprit > Rom"` | |
SpritGinGenever int `json:"Sprit > Gin & Genever"` | |
SpritBitterApRitif int `json:"Sprit > Bitter & Apéritif"` | |
SpritSherryPortvin int `json:"Sprit > Sherry & Portvin"` | |
SpritBrandy int `json:"Sprit > Brandy"` | |
SpritGrappaOgFruktbrennevin int `json:"Sprit > Grappa og fruktbrennevin"` | |
SpritVermut int `json:"Sprit > Vermut"` | |
SpritTequila int `json:"Sprit > Tequila"` | |
SpritFruktbrennevin int `json:"Sprit > Fruktbrennevin"` | |
SpritArmagnac int `json:"Sprit > Armagnac"` | |
SpritKlare int `json:"Sprit > Klare"` | |
} `json:"categoryPathHierarchy.lvl1"` | |
} `json:"facets"` | |
FacetsStats struct { | |
PriceValue struct { | |
Min int `json:"min"` | |
Max int `json:"max"` | |
Avg int `json:"avg"` | |
Sum int `json:"sum"` | |
} `json:"price.value"` | |
AvailableInFormatted struct { | |
Min int `json:"min"` | |
Max int `json:"max"` | |
Avg int `json:"avg"` | |
Sum int `json:"sum"` | |
} `json:"availableInFormatted"` | |
} `json:"facets_stats,omitempty"` | |
ExhaustiveFacetsCount bool `json:"exhaustiveFacetsCount"` | |
ExhaustiveNbHits bool `json:"exhaustiveNbHits"` | |
Query string `json:"query"` | |
Params string `json:"params"` | |
Index string `json:"index"` | |
} `json:"results"` | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment