scraping-instagram-location-posts

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Scraping Instagram Location Posts

抓取Instagram位置标签帖子

Exports Instagram posts tagged at any physical location. Uses Instagram's location ID or place name to collect geo-tagged content.
导出带有任意实体地点标签的Instagram帖子。可通过Instagram位置ID或地点名称来收集带地理标签的内容。

Prerequisites

前提条件

  • APIFY_TOKEN
    environment variable set
  • Optional: Apify MCP server installed
  • 已设置
    APIFY_TOKEN
    环境变量
  • 可选:已安装Apify MCP服务器

Inputs

输入参数

ParameterTypeRequiredDefaultNotes
startUrls
arrayOptional
[]
Instagram location page URLs
locationIds
arrayOptional
[]
Instagram location IDs
maxItems
numberOptionalUnlimitedMaximum posts to return
until
stringOptionalDate filter (YYYY-MM-DD)
customMapFunction
stringOptionalJavaScript function to transform each output object
参数类型是否必填默认值说明
startUrls
array可选
[]
Instagram地点页面链接
locationIds
array可选
[]
Instagram位置ID
maxItems
number可选无限制返回的最大帖子数量
until
string可选日期筛选条件(格式:YYYY-MM-DD)
customMapFunction
string可选用于转换每个输出对象的JavaScript函数

Workflow

工作流程

Progress:
- [ ] Step 1: Resolve location ID
- [ ] Step 2: Run instagram-location-scraper
- [ ] Step 3: Poll for SUCCEEDED
- [ ] Step 4: Deliver post dataset
Progress:
- [ ] Step 1: Resolve location ID
- [ ] Step 2: Run instagram-location-scraper
- [ ] Step 3: Poll for SUCCEEDED
- [ ] Step 4: Deliver post dataset

Step 2: Run the Actor

步骤2:运行Actor

Recommended — run_actor.js (handles waiting, output, and file saving automatically):
bash
undefined
推荐方式 — run_actor.js(自动处理等待、输出和文件保存):
bash
undefined

Quick answer (prints table to chat)

Quick answer (prints table to chat)

node scripts/run_actor.js
--actor "apidojo~instagram-location-scraper"
--input '{"param": "value"}'
node scripts/run_actor.js
--actor "apidojo~instagram-location-scraper"
--input '{"param": "value"}'

Save as CSV

Save as CSV

node scripts/run_actor.js
--actor "apidojo~instagram-location-scraper"
--input '{"param": "value"}'
--output YYYY-MM-DD_results.csv --format csv
node scripts/run_actor.js
--actor "apidojo~instagram-location-scraper"
--input '{"param": "value"}'
--output YYYY-MM-DD_results.csv --format csv

Save as JSON

Save as JSON

node scripts/run_actor.js
--actor "apidojo~instagram-location-scraper"
--input '{"param": "value"}'
--output YYYY-MM-DD_results.json --format json
> `APIFY_TOKEN` must be set in environment or `.env` file.

**If Apify MCP is available:**
Tool: apify:run-actor Actor: "apidojo~instagram-location-scraper" Input: { "locationIds": ["<LOCATION_ID>"], "maxItems": 100 }

**REST API fallback:**
```bash
curl -X POST \
  "https://api.apify.com/v2/acts/apidojo~instagram-location-scraper/runs?token=$APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"locationIds": ["<LOCATION_ID>"], "maxItems": 100}'
Save
id
as
RUN_ID
. Poll until
status = SUCCEEDED
:
bash
curl "https://api.apify.com/v2/actor-runs/$RUN_ID?token=$APIFY_TOKEN" | grep '"status"'
Fetch results:
bash
curl "https://api.apify.com/v2/actor-runs/$RUN_ID/dataset/items?token=$APIFY_TOKEN&format=json"
node scripts/run_actor.js
--actor "apidojo~instagram-location-scraper"
--input '{"param": "value"}'
--output YYYY-MM-DD_results.json --format json
> `APIFY_TOKEN`必须在环境变量或`.env`文件中设置。

**如果Apify MCP可用:**
Tool: apify:run-actor Actor: "apidojo~instagram-location-scraper" Input: { "locationIds": ["<LOCATION_ID>"], "maxItems": 100 }

**REST API备选方案:**
```bash
curl -X POST \
  "https://api.apify.com/v2/acts/apidojo~instagram-location-scraper/runs?token=$APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"locationIds": ["<LOCATION_ID>"], "maxItems": 100}'
将返回的
id
保存为
RUN_ID
,轮询直到
status = SUCCEEDED
bash
curl "https://api.apify.com/v2/actor-runs/$RUN_ID?token=$APIFY_TOKEN" | grep '"status"'
获取结果:
bash
curl "https://api.apify.com/v2/actor-runs/$RUN_ID/dataset/items?token=$APIFY_TOKEN&format=json"

Step 3: Handle Edge Cases

步骤3:处理边缘情况

  • Location ID not found: Invalid ID or location removed from Instagram — report to user.
  • Low post volume: Niche locations may have < 20 posts — return all available.
  • Private account posts in feed: Metadata visible but media may be restricted.
  • 未找到位置ID:ID无效或该地点已从Instagram移除——向用户反馈此问题。
  • 帖子数量少:小众地点的帖子可能不足20条——返回所有可用帖子。
  • 动态中的私人账号帖子:元数据可见,但媒体内容可能受限。

Output Format

输出格式

undefined
undefined

Instagram Location Posts: <location name>

Instagram Location Posts: <location name>

Location ID: <id> | Posts collected: N
Post IDAuthorCaption (truncated)LikesCommentsTypeTimestamp
.....................
undefined
Location ID: <id> | Posts collected: N
Post IDAuthorCaption (truncated)LikesCommentsTypeTimestamp
.....................
undefined

Troubleshooting

故障排除

Don't have the Location ID: Visit
https://www.instagram.com/explore/locations/
and search — the ID is in the URL. 0 results: Location may have been renamed or merged — search for new ID.
**没有位置ID?**访问
https://www.instagram.com/explore/locations/
并搜索目标地点——ID包含在页面链接中。 返回0条结果:该地点可能已更名或合并——搜索新的位置ID。