要从URL中获取.aspx页面名称,您可以使用以下方法:
const url = new URL('https://example.com/somefolder/somepage.aspx');
const pageName = url.pathname.split('/').pop();
console.log(pageName); // 输出:somepage.aspx
from urllib.parse import urlparse
url = 'https://example.com/somefolder/somepage.aspx'
parsed_url = urlparse(url)
page_name = parsed_url.path.split('/')[-1]
print(page_name) # 输出:somepage.aspx
using System;
string url = "https://example.com/somefolder/somepage.aspx";
Uri uri = new Uri(url);
string pageName = uri.Segments.Length > 0 ? uri.Segments[uri.Segments.Length - 1] : "";
Console.WriteLine(pageName); // 输出:somepage.aspx
这些方法都可以从URL中提取出.aspx页面名称。
领取专属 10元无门槛券
手把手带您无忧上云