小编HAR*_*PAI的帖子

如何根据Python中动态给出的多个不同标签获取shopify产品?

我正在尝试通过基于标签的过滤来从 Shopify 获取产品。标签将是动态的,不止一个,并且会发生变化。

import json
import time
import requests

API_KEY = 'xxxx'
PASSWORD = 'xxxx'
SHOP_NAME = 'xxxx'
API_VERSION = '2020-04' #change to the API version
shop_url = "https://%s:%s@%s.myshopify.com/admin/api/%s" % (API_KEY, PASSWORD, SHOP_NAME, API_VERSION)

def callShopifyGraphQL(GraphQLString, data):
    headers = {
        "X-Shopify-Storefront-Access-Token": 'xxxxxx',
        "accept":"application/json"      
    }
    response = requests.post(shop_url+'/graphql', json={'query': GraphQLString, 'variables': data}, headers=headers)
    answer = json.loads(response.text)
    return answer['data']

str1 = '0-12'
str2 = 'physical'

graphQLquery7 = """ {
  products(first:100, query:"tag:$tags") {
    edges {
      node {
        id
        tags
        title
        onlineStoreUrl
      }
    } …
Run Code Online (Sandbox Code Playgroud)

shopify graphql shopify-api-node shopify-api

3
推荐指数
1
解决办法
5168
查看次数

标签 统计

graphql ×1

shopify ×1

shopify-api ×1

shopify-api-node ×1