Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
308 views
in Technique[技术] by (71.8m points)

求问,如何将两个excel表的数据循环post到wordpress?

1.需要将excel表格1里的关键词和excel表格2里的图片url循环

from woocommerce import API 
import pandas as pd 

wcapi = API(
url="https://www.xxx.com", ? ? 
consumer_key="ck_", ? ? 
consumer_secret="cs_", ? ? 
version="wc/v3" ) 

def wcpdo(A, categories="126", images="images"): 
     data2 = ?{ 
        "name":A, 
        "type":"simple", 
        "regular_price":"2.9", 
        "description":'''Material :nylon/spandex /Lycra cloth''', 
        "short_description":'''Brand Name: ?Bilymate''',           "categories":[{"id":categories}], 
        "images":[{"src":images}], ? ? ? ? ? ? 
        } ? ?
        
     data = {"create": [data2]} 
     return data 
     

sheet = pd.read_excel(io="C:Desktoptutttcii.xlsx") 
sheet2 = pd.read_excel(io="C:Desktoptuttttu.xlsx") 

for (x,y) in zip(sheet,sheet2):
         up = wcpdo(A=x,images=y)
         print(wcapi.post("products/batch", up).json())
         

2.我需要将data2里的name替换和images替换成excel里的数据。

3.现在的问题是代码可以运行,但是不能循环,一次只能post一个产品。

求问大神,我该怎么写呢,万分感谢!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...