reichelt/picture.go

19 lines
462 B
Go
Raw Normal View History

2017-03-12 14:47:59 +01:00
package reichelt
import (
"io"
"strconv"
)
// gets the product image of a reichelt article using the internal Part number
// the reader will return a image/jpg file
func (c *Connection) GetImage(p Part, w, h uint) (io.ReadCloser, error) {
resp, err := c.client.Get("https://www.reichelt.de/artimage/resize_" + strconv.Itoa(int(w)) + "x" + strconv.Itoa(int(h)) + "/" + strconv.Itoa(p.Number))
if err != nil {
return nil, err
}
return resp.Body, nil
}