使用shopify python api从shopify中查找具有特定日期范围的客户

2024-09-28 22:22:01 发布

您现在位置:Python中文网/ 问答频道 /正文

如何从shopify导入具有特定日期范围的客户,即使用日期过滤器导入客户?在

导入不带过滤器的客户请参照以下代码:

shop_url = "https://%s:%s@%s.myshopify.com/admin/" % (self.api_key_shopify, 
                                                    self.password_shopify, self.name)

shopify.ShopifyResource.set_site(shop_url)
customer_list = shopify.Customer.find()

Tags: key代码namehttpsselfcomapiurl
1条回答
网友
1楼 · 发布于 2024-09-28 22:22:01

As you can see from the documentation,为了获得在特定范围内创建的客户,您需要随请求一起传递的参数是created_at_min和{}。除非您想手动键入时间戳,否则我们将需要来自^{}模块的^{}对象。在

from datetime import datetime
time_format = "%Y-%m-%dT%H:%M:%S+00:00"
min_date = datetime(year=2016, month=5, day=1).strftime(time_format)
max_date = datetime(year=2016, month=6, day=1).strftime(time_format)

我们与strftime方法一起使用的格式化字符串将以shoppify文档要求的格式提供时间,并硬编码UTC时区。如果您想使用不同的时区,您可以用不同的时间偏移量硬编码,或者使用pytz module。在

现在,对于实际调用API。使用Shopify resources的find方法时,将属性名/值对作为关键字参数传递,如下所示:

^{pr2}$

瞧,这应该返回一个Customer资源的列表,如果没有匹配项,则返回一个空列表。在

相关问题 更多 >