zapier-IOError:[Errno 30]只读文件系统:“ products.cvs”

时间:2018-07-05 17:25:06

标签: python zapier

对于那些了解Zapier的人来说,我正在使用Python制作zap,它将每月触发以下代码。该代码从使用shopify的网站上提取产品,并在.csv文件中返回值。该代码在命令提示符下工作正常,但是我在Zapier中收到上述错误。有人知道如何解决该错误吗?请参考下面来自错误的行:

以open('products.csv','w')为f:

import csv
import json
import urllib2
import sys

url = 'https://blahblah.com'

def get_page(page):
    data = urllib2.urlopen(url + '?page={}'.format(page)).read()
    products = json.loads(data)['products']
    return products

with open('products.csv', 'w') as f:
    writer = csv.writer(f)
    writer.writerow(['Category', 'Name', 'Price', 'Vendor'])
    page = 1
    products = get_page(page)
    while products:
        for product in products:
            name = product['title']
            category = product['product_type']
            vendor = product['vendor']
            for variant in product['variants']:
                price = variant['price']
                row = [category, name, price, vendor]
                row = [uni.encode('utf8') for uni in row]
                writer.writerow(row)
        page += 1
        products = get_page(page)

0 个答案:

没有答案