---
title: extractUrlPath – ฟังก์ชันดึง Path จาก URL
url: https://www.thepexcel.com/functions/n8n/string-functions/extract-url-path-n8n/
type: function-explainer
program: n8n
syntax: extractUrlPath(url)
date: 2025-12-16
updated: 2025-12-17
scores:
  popularity: 5
  difficulty: 3
  usefulness: 5
---

# extractUrlPath – ฟังก์ชันดึง Path จาก URL

> ดึง path จาก URL

## คำอธิบาย

extractUrlPath ดึง path segment จาก URL โดยแยกออกจากโดเมน ฟังก์ชันนี้มีประโยชน์ในการวิเคราะห์ URL หรือสกัดเส้นทางสำหรับการประมวลผล

## Syntax

```excel
extractUrlPath(url)
```

**Variant**

```excel
$json.website.extractUrlPath()
```

ใช้เป็น method เมื่อ $json.website มี URL

## Arguments

| Name | Required | Type | Default | Description |
| --- | --- | --- | --- | --- |
| url | Yes | string |  | URL ที่ต้องการดึก path |

## เคสการใช้งาน

### วิเคราะห์ Navigation

ดึก path จากผู้เยี่ยมชมเพื่อวิเคราะห์ว่าคนไปที่หน้าใด

_เหมาะกับ:_ url-analysis

### สกัด Endpoints

ดึก path จาก API URLs เพื่อแยก endpoint

_เหมาะกับ:_ api-parsing

## ตัวอย่าง

### 1. ตัวอย่างที่ 1: ดึก Path พื้นฐาน

```excel
{{ extractUrlPath('https://example.com/products/category/item') }}
```

**ผลลัพธ์:** `/products/category/item`

ฟังก์ชันจะดึก path '/products/category/item' จากที่อยู่เว็บไซต์ สมบูรณ์ ทำให้เราได้เพียงส่วนของเส้นทางเท่านั้น

### 2. ตัวอย่างที่ 2: ดึก Path จาก API

```excel
{{ extractUrlPath($json.apiUrl) }}
```

**ผลลัพธ์:** `/api/v1/users/123`

สูตรนี้ดึก path '/api/v1/users/123' จากที่อยู่ API ที่เก็บไว้ในข้อมูลอินพุต เพื่อแยกส่วนเส้นทางออกมาใช้งาน

### 3. ตัวอย่างที่ 3: วิเคราะห์ Navigation

```excel
{{ $json.visits.map(v => extractUrlPath(v.url)) }}
```

**ผลลัพธ์:** `[/home, /products, /blog, /contact]`

ดึก path จากทุก visited URLs เพื่อวิเคราะห์ navigation ของผู้เยี่ยมชม ให้เห็นว่าคนเข้าไปที่หน้าใดบ้าง ได้ผลในการวิเคราะห์พฤติกรรมผู้ใช้งาน

## หมายเหตุเพิ่มเติม

⚠️ ฟังก์ชัน extractUrlPath() ใช้ร่วมกับ extractDomain() เพื่อแยกส่วนต่างๆ ของ URL อย่างได้ผล หากต้องการดึง query parameters ให้ใช้วิธีอื่นแทน extractUrlPath() เนื่องจากฟังก์ชันนี้จะลบส่วน query string ออกให้โดยอัตโนมัติ จึงเหมาะสำหรับกรณีที่ต้องการเพียง path ส่วนเท่านั้น

## คำถามที่พบบ่อย

**Q: extractUrlPath() จะลบ query parameters หรือไม่?**

ขึ้นอยู่กับการใช้งาน โดยปกติจะลบ query strings และเหลือเพียง path

**Q: extractUrlPath() จะรับ relative URLs ได้หรือ?**

ได้ ฟังก์ชันจะดึก path segment ออกจากส่วนของ URL ที่ป้อน

**Q: ใช้ extractUrlPath() เมื่อไหร่ในการทำงาน?**

ใช้เมื่อต้องการดึก path จาก URL เพื่อวิเคราะห์ navigation หรือ API endpoints

## ฟังก์ชันที่เกี่ยวข้อง

- [extractDomain – ฟังก์ชันดึงชื่อโดเมน](https://www.thepexcel.com/functions/n8n/string-functions/extract-domain-n8n/)
- [extractUrl – ฟังก์ชันดึง URL จากข้อความ](https://www.thepexcel.com/functions/n8n/string-functions/extract-url-n8n/)
- [isUrl – ฟังก์ชันตรวจสอบว่าเป็น URL ถูกต้องหรือไม่](https://www.thepexcel.com/functions/n8n/string-functions/is-url-n8n/)
- [map – แปลงแต่ละรายการในอาร์เรย์ (transform elements)](https://www.thepexcel.com/functions/n8n/array-functions/map-n8n/)

---

_Source: [https://www.thepexcel.com/functions/n8n/string-functions/extract-url-path-n8n/](https://www.thepexcel.com/functions/n8n/string-functions/extract-url-path-n8n/)_
