|
@@ -1,39 +1,39 @@
|
|
package wordpress
|
|
package wordpress
|
|
|
|
|
|
import (
|
|
import (
|
|
- util "kkscrap-go/controllers/scraper/util"
|
|
|
|
- "testing"
|
|
|
|
-
|
|
|
|
|
|
+ "commerce-crwaler/util"
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
+ "os"
|
|
|
|
+ "testing"
|
|
)
|
|
)
|
|
|
|
|
|
func TestGetImages(t *testing.T) {
|
|
func TestGetImages(t *testing.T) {
|
|
body, err := util.Get("https://seoulknit.com/shop/collar-half-sleeved-top_blue/")
|
|
body, err := util.Get("https://seoulknit.com/shop/collar-half-sleeved-top_blue/")
|
|
assert.Equal(t, nil, err)
|
|
assert.Equal(t, nil, err)
|
|
imgs := getImages(body)
|
|
imgs := getImages(body)
|
|
- assert.Equal(t, "https://seoulknit.com/wp-content/uploads/2021/05/abito_0594-scaled-454x681.jpg", imgs[0].Path)
|
|
|
|
- assert.Equal(t, "https://seoulknit.com/wp-content/uploads/2021/05/abito_0594-scaled-100x100.jpg", imgs[1].Path)
|
|
|
|
|
|
+ assert.Equal(t, "https://seoulknit.com/wp-content/uploads/2021/05/abito_0594-scaled-454x681.jpg", imgs[0])
|
|
|
|
+ assert.Equal(t, "https://seoulknit.com/wp-content/uploads/2021/05/abito_0594-scaled-100x100.jpg", imgs[1])
|
|
|
|
|
|
body, err = util.Get("https://www.dollshecraft.com/product/amanda-beauty-26f-classic-maxi-65cm-special-package-2/")
|
|
body, err = util.Get("https://www.dollshecraft.com/product/amanda-beauty-26f-classic-maxi-65cm-special-package-2/")
|
|
assert.Equal(t, nil, err)
|
|
assert.Equal(t, nil, err)
|
|
imgs = getImages(body)
|
|
imgs = getImages(body)
|
|
- assert.Equal(t, "https://cdn.dollshecraft.com/wp-content/uploads/2018/08/Amanda-Beauty_558743_01.jpg", imgs[0].Path)
|
|
|
|
|
|
+ assert.Equal(t, "https://cdn.dollshecraft.com/wp-content/uploads/2018/08/Amanda-Beauty_558743_01.jpg", imgs[0])
|
|
|
|
|
|
body, err = util.Get("https://www.shoprootscience.com/shop/arctic-c-vitamin-c-serum")
|
|
body, err = util.Get("https://www.shoprootscience.com/shop/arctic-c-vitamin-c-serum")
|
|
assert.Equal(t, nil, err)
|
|
assert.Equal(t, nil, err)
|
|
imgs = getImages(body)
|
|
imgs = getImages(body)
|
|
- assert.Equal(t, "https://www.shoprootscience.com/wp-content/uploads/2020/10/Arctic-C-product-511x634.jpg", imgs[0].Path)
|
|
|
|
- assert.Equal(t, "https://www.shoprootscience.com/wp-content/uploads/2020/10/Arctic-C-product.jpg", imgs[1].Path)
|
|
|
|
|
|
+ assert.Equal(t, "https://www.shoprootscience.com/wp-content/uploads/2020/10/Arctic-C-product-511x634.jpg", imgs[0])
|
|
|
|
+ assert.Equal(t, "https://www.shoprootscience.com/wp-content/uploads/2020/10/Arctic-C-product.jpg", imgs[1])
|
|
|
|
|
|
body, err = util.Get("https://strandbergguitars.com/product/boden-6-dr-titanium/")
|
|
body, err = util.Get("https://strandbergguitars.com/product/boden-6-dr-titanium/")
|
|
assert.Equal(t, nil, err)
|
|
assert.Equal(t, nil, err)
|
|
imgs = getImages(body)
|
|
imgs = getImages(body)
|
|
- assert.Equal(t, "https://strandbergguitars.com/cdn-cgi/image/onerror=redirect,quality=85,format=auto,metadata=copyright,width=600,height=901,fit=cover/wp-content/uploads/2021/04/bd6ct-20dr-k-p-ti_6.png", imgs[0].Path)
|
|
|
|
|
|
+ assert.Equal(t, "https://strandbergguitars.com/cdn-cgi/image/onerror=redirect,quality=85,format=auto,metadata=copyright,width=600,height=901,fit=cover/wp-content/uploads/2021/04/bd6ct-20dr-k-p-ti_6.png", imgs[0])
|
|
|
|
|
|
body, err = util.Get("https://lanbelle.com/product/%EB%9E%91%EB%B2%A8-%EC%88%98%ED%8D%BC%EB%82%B4%EC%B8%84%EB%9F%B4-%ED%81%AC%EB%A6%BC/")
|
|
body, err = util.Get("https://lanbelle.com/product/%EB%9E%91%EB%B2%A8-%EC%88%98%ED%8D%BC%EB%82%B4%EC%B8%84%EB%9F%B4-%ED%81%AC%EB%A6%BC/")
|
|
assert.Equal(t, nil, err)
|
|
assert.Equal(t, nil, err)
|
|
imgs = getImages(body)
|
|
imgs = getImages(body)
|
|
- assert.Equal(t, "https://strandbergguitars.com/cdn-cgi/image/onerror=redirect,quality=85,format=auto,metadata=copyright,width=600,height=901,fit=cover/wp-content/uploads/2021/04/bd6ct-20dr-k-p-ti_6.png", imgs[0].Path)
|
|
|
|
|
|
+ assert.Equal(t, "https://strandbergguitars.com/cdn-cgi/image/onerror=redirect,quality=85,format=auto,metadata=copyright,width=600,height=901,fit=cover/wp-content/uploads/2021/04/bd6ct-20dr-k-p-ti_6.png", imgs[0])
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@@ -73,7 +73,16 @@ func TestGetWordPressProduct(t *testing.T) {
|
|
body, err = util.Get("https://strandbergguitars.com/product/boden-6-dr-titanium/")
|
|
body, err = util.Get("https://strandbergguitars.com/product/boden-6-dr-titanium/")
|
|
assert.Equal(t, nil, err)
|
|
assert.Equal(t, nil, err)
|
|
ret = getProduct(body)
|
|
ret = getProduct(body)
|
|
- assert.Equal(t, ret.Sku, "BD6CT-20DR-K-P-TI")
|
|
|
|
|
|
+ assert.Equal(t, "BD6CT-20DRB-K-P-TI", ret.Sku)
|
|
|
|
+
|
|
|
|
+ t.Run("상품설명", func(t *testing.T) {
|
|
|
|
+ body, err := util.Get("https://www.mehisox.com/shop/sn388/")
|
|
|
|
+ assert.Equal(t, nil, err)
|
|
|
|
+ html := getProductDescription(body)
|
|
|
|
+ os.WriteFile("c:\\temp\\test.html", []byte(html), 0644)
|
|
|
|
+ assert.Equal(t, ``, html)
|
|
|
|
+ })
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
func TestGetCategories(t *testing.T) {
|
|
func TestGetCategories(t *testing.T) {
|