集成

将Shifter与以下工具配合使用 Zapier

Zapier 没有原生代理字段——但 Code by Zapier 操作和 Webhooks by Zapier 操作均支持通过几行 JavaScript 或 Python,经由 Shifter 的 Web Scraping API 发起出站请求。

快速入门

安装

// Add a 'Code by Zapier' or 'Webhooks by Zapier' action — no install required.

基本用法

// In a "Code by Zapier" (Run JavaScript) action:
const apiKey    = inputData.shifter_api_key;
const targetUrl = inputData.target_url;
const country   = inputData.country || "us";

const params = new URLSearchParams({
  api_key:    apiKey,
  url:        targetUrl,
  country:    country,
  render_js:  "1",
  session_id: inputData.zap_run_id,   // sticky residential IP for this run
});

const response = await fetch(`https://scrape.shifter.io/v1?${params}`);
const html     = await response.text();

output = { html, status: response.status, length: html.length };

功能特性

适用于所有包含 Code by Zapier 或 Webhooks by Zapier 的 Zapier 套餐
JavaScript 或 Python 运行时——选择最适合你团队的那个
通过传递 session_id(例如 Zap 运行 ID)在每次 Zap 运行中使用固定住宅 IP
通过 country 查询参数在 195+ 个国家进行地理定向
内置无头浏览器渲染(render_js=1),无需额外步骤即可处理 JS 密集型页面
兼容 Storage by Zapier 和 Vault 进行凭据管理

示例

Code by Zapier——带粘性会话的 JavaScript

运行自定义 JS 步骤,通过 Shifter Web Scraping API 抓取页面。传入从 Zap 运行 ID 派生的 session_id,使同一次运行中的每个步骤共享同一个住宅 IP。

// "Code by Zapier" action -> Run JavaScript
//
// inputData.target_url      -> https://example.co.uk/products
// inputData.country         -> "uk"
// inputData.shifter_api_key -> your Shifter API key (Storage by Zapier secret)
// inputData.zap_run_id      -> Zap run id from the trigger

const params = new URLSearchParams({
  api_key:    inputData.shifter_api_key,
  url:        inputData.target_url,
  country:    inputData.country || "us",
  render_js:  "1",                       // headless browser
  session_id: inputData.zap_run_id,      // sticky IP per Zap run
});

const response = await fetch(`https://scrape.shifter.io/v1?${params}`);
const html     = await response.text();

// Extract a value with a regex — Zapier's Code action doesn't bundle cheerio.
const titleMatch = html.match(/<title>([\s\S]*?)<\/title>/i);
const priceMatch = html.match(/class=["']price["'][^>]*>([^<]+)/i);

output = {
  status: response.status,
  title:  titleMatch?.[1]?.trim(),
  price:  priceMatch?.[1]?.trim(),
  length: html.length,
};

Code by Zapier——Python(urllib)

Zapier 的 Python 运行时足以调用 Web Scraping API 并解析响应。适合偏好编写 Python 且需要访问标准库的场景。

# "Code by Zapier" action -> Run Python
import urllib.request
import urllib.parse
import re

params = urllib.parse.urlencode({
    "api_key":    input_data["shifter_api_key"],
    "url":        input_data["target_url"],
    "country":    input_data.get("country", "us"),
    "render_js":  "1",
    "session_id": input_data["zap_run_id"],
})

req = urllib.request.Request(
    f"https://scrape.shifter.io/v1?{params}",
    headers={"User-Agent": "ZapierShifterClient/1.0"},
)

with urllib.request.urlopen(req, timeout=30) as resp:
    html   = resp.read().decode("utf-8", errors="replace")
    status = resp.status

# Extract whatever the Zap needs.
title  = (re.search(r"<title>(.*?)</title>", html, re.IGNORECASE | re.DOTALL) or [None, ""])[1].strip()
prices = re.findall(r'class="price"[^>]*>([^<]+)', html)

return {
    "status": status,
    "title":  title,
    "prices": prices[:10],
}

Webhooks by Zapier——自定义请求

如果你的 Zap 不允许 Code 步骤(某些套餐),可使用 Webhooks by Zapier 的「Custom Request」操作,通过查询参数直接调用 Web Scraping API。

# Action: Webhooks by Zapier -> Custom Request
#
# Method:  GET
# URL:     https://scrape.shifter.io/v1
# Query String Params:
#   api_key    = {{credentials.shifter_api_key}}
#   url        = {{trigger.target_url}}
#   country    = us
#   render_js  = 1
#   session_id = {{trigger.zap_run_id}}
#
# Headers:
#   User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36
#
# Output:
#   The response body is the fully-rendered HTML, returned to Zapier
#   as a single output field. Pipe it into a Filter, Formatter, or
#   another Code step to parse what you need.
#
# Notes:
# - session_id uses the Zap run id so all requests within one run
#   share the same residential IP (sticky session, 10 min default).
# - country can be sourced from a previous step
#   ({{step1.country}}) for per-item geo routing.

Storage by Zapier——密钥管理

不要将 API 密钥直接粘贴到 Code 操作中。使用 Storage by Zapier(或企业套餐的 Zapier Vault)对你的 Shifter API 密钥进行加密存储,并在多个 Zap 中复用。

// One-off setup (run once via Code by Zapier):
//
//   await fetch("https://store.zapier.com/api/records", {
//     method: "POST",
//     headers: { "X-Secret": ZAPIER_STORAGE_SECRET },
//     body: JSON.stringify({
//       shifter_api_key: "YOUR_SHIFTER_API_KEY",
//     }),
//   });
//
// Then in any future Zap that needs the Shifter API key:

const storageRes = await fetch(
  "https://store.zapier.com/api/records?key=shifter_api_key",
  { headers: { "X-Secret": process.env.ZAPIER_STORAGE_SECRET } },
);
const { shifter_api_key } = await storageRes.json();

const params = new URLSearchParams({
  api_key:    shifter_api_key,
  url:        inputData.target_url,
  country:    "us",
  render_js:  "1",
  session_id: inputData.run_id,
});

const response = await fetch(`https://scrape.shifter.io/v1?${params}`);
// ... use response as in the previous examples
常见问题

常见问题

关于将 Shifter 与 Zapier 搭配使用的常见问题。

Not on the standard Webhooks action — Zapier's HTTP layer doesn't expose a proxy field. The supported workarounds are Code by Zapier (run a JavaScript or Python step that calls the Shifter Web Scraping API) or the Webhooks Custom Request action pointed at https://scrape.shifter.io/v1 with the country, render_js, and session_id query params.

立即开始

开始将Shifter与以下工具配合使用 Zapier

通过 Code by Zapier 或 Webhooks Custom Request 将 Shifter 的 205M+ 住宅和 ISP 代理添加到您的 Zap 中。支持按运行粘性会话、按条目地理定向、内置无头渲染以及完整的 Storage / Vault 凭证支持。

免费试用 Shifter几分钟内完成设置,随时可取消。