Initial commit.

Example output:
Got 580 offers. Filtered offers: 3
           ID|     Ram|             HDD|                           CPU|    Price|   Score|  Reduce time|Specials
  SB57-931121|  128 GB|  2x 2 TB (4096)|  Intel Xeon E5-1650V2 (12518)|  57.00 €|  103.12|      53h 53m|ECC, Ent. HDD, iNIC
  SB69-927780|  128 GB|  2x 2 TB (4096)|  Intel Xeon E5-1650V3 (13335)|  69.00 €|   89.92|      49h 39m|ECC, Ent. HDD, iNIC
  SB76-910394|  128 GB|  3x 2 TB (6144)|  Intel Xeon E5-1650V2 (12518)|  76.00 €|   82.73|      01h 21m|ECC, Ent. HDD, iNIC
This commit is contained in:
Mahmoud Rahbar Azad 2018-10-22 23:55:29 +02:00
commit 66001f861f
WARNING! Although there is a key with this ID in the database it does not verify this commit! This commit is SUSPICIOUS.
GPG key ID: 7DBBD39E2BFEB784
7 changed files with 293 additions and 0 deletions

29
client/client.go Normal file
View file

@ -0,0 +1,29 @@
package client
import (
"encoding/json"
"net/http"
"time"
)
type Client struct {
httpClient *http.Client
}
func NewClient() *Client {
crawler := &Client{
&http.Client{Timeout: 10 * time.Second} ,
}
return crawler
}
func (c *Client) DoRequest(url string, target interface{}) error {
r, err := c.httpClient.Get(url)
if err != nil {
return err
}
defer r.Body.Close()
return json.NewDecoder(r.Body).Decode(target)
}