我一直在尝试通过其API将Aliexpress产品添加到Woocommerce中,但是当该过程运行时,它将每个图像保存到一个图像文件中,而且我的托管帐户通常很快会耗尽资源。
如何将图像保存为外部URL,而不是将每个条目保存到单个图像文件中?
from woocommerce import API
wcapi = API(
url="https://example.com",
consumer_key="consumer_key",
consumer_secret="consumer_secret",
wp_api=True,
version="wc/v3"
)
data = {
"name": "Premium Quality",
"type": "simple",
"regular_price": "21.99",
"description": "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.",
"short_description": "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.",
"categories": [
{
"id": 9
},
{
"id": 14
}
],
"images": []
}
for number, url in enumerate(getdetailallimage):
data["images"].append({"src": url, "position": number})
print(wcapi.post("products", data).json())