Skip to main content

A tool that bulk merges tricky relative URLs.

Project description

The explanations in English, Simplified Chinese, and Spanish are provided below. 下面提供了英语、简体中文和西班牙语的说明。 Las explicaciones en inglés, chino simplificado y español se proporcionan a continuación.

linklinkライブラリについて

概要

linklinkライブラリは、ややこしい相対URLの結合を簡単に行うためのPythonツールです。このツールの名前の「linklink」は、URL(link)をつなげる(linkする)ことを意味します。

特徴

  • 複雑な相対URLの結合を一括でやってくれます。
  • URLの結合において、例えば次のような場合を処理します:
    • "a.com/b"というページで"c"にアクセスすると"a.com/b/c"に飛ぶが、"/c"にアクセスすると"a.com/c"に飛ぶ。

使い方

import linklink

result = linklink.link(
    target_url="/hoge3",
    page_url="https://example.com/hoge"
)
print(result)   # -> https://example.com/hoge3

# 他の結合パターン
print(linklink.link("http://example2.com/hoge", "https://example.com/hoge"))    # -> http://example2.com/hoge

注意点

page_urlのフォーマットの正確さを確認してください。不正確なフォーマットは例外を引き起こす可能性があります。

# 間違ったpage_urlフォーマットによる例外の例
print(linklink.link("//hoge3.com/fuga", "wrong://example.com/hoge"))    # -> Exception: [linklink error] invalid page_url format.

Introduction to linklink Library

Overview

The linklink library is a Python tool designed to streamline the concatenation of tricky relative URLs. This tool helps manage the nuanced rules around combining URLs, making it easier to navigate complex web structures. The name "linklink" refers to the action of connecting or linking URLs.

Features

  • It automatically combines intricate relative URLs.
  • When dealing with URL combination, it handles the following example case:
    • On page "a.com/b", accessing "c" leads to "a.com/b/c", while accessing "/c" leads to "a.com/c".

How to Use

import linklink

result = linklink.link(
    target_url="/page3",
    page_url="https://example.com/page"
)
print(result)   # -> https://example.com/page3

# Other combination patterns
print(linklink.link("http://example2.com/page", "https://example.com/page"))    # -> http://example2.com/page

Caution

Please ensure the correctness of the page_url format. Incorrect formats may cause exceptions.

Example

# Example of wrong page_url format causing an exception
print(linklink.link("//page3.com/section", "wrong://example.com/page")) # -> Exception: [linklink error] invalid page_url format.

linklink库介绍

概述

linklink库是一个Python工具,旨在简化相对URL的复杂连接。"linklink"这个名字表达的是连接或链接URL的动作。

特点

  • 它可以自动合并复杂的相对URL。
  • 在处理URL连接时,它可以处理如下的例子:
    • 在"a.com/b"这个页面上,访问"c"会导向"a.com/b/c",而访问"/c"会导向"a.com/c"。

如何使用

import linklink

result = linklink.link(
    target_url="/yezi3",
    page_url="https://example.com/yezi"
)
print(result)   # -> https://example.com/yezi3

# 其他组合模式
print(linklink.link("http://example2.com/yezi", "https://example.com/yezi"))    # -> http://example2.com/yezi

注意

请确保page_url格式的正确性。不正确的格式可能会引发异常。

例子

# 错误的page_url格式引发异常的例子
print(linklink.link("//yezi3.com/jie", "wrong://example.com/yezi")) # -> Exception: [linklink error] invalid page_url format.

Introducción a la Biblioteca linklink

Descripción General

La biblioteca linklink es una herramienta de Python diseñada para simplificar la concatenación de URLs relativas complicadas. El nombre "linklink" se refiere a la acción de conectar o enlazar URLs.

Características

  • Combina automáticamente URLs relativas complicadas.
  • En la combinación de URLs, maneja el siguiente caso de ejemplo:
    • En la página "a.com/b", acceder a "c" lleva a "a.com/b/c", mientras que acceder a "/c" lleva a "a.com/c".

Cómo Usar

import linklink

result = linklink.link(
    target_url="/pagina3",
    page_url="https://example.com/pagina"
)
print(result)   # -> https://example.com/pagina3

# Otros patrones de combinación
print(linklink.link("http://example2.com/pagina", "https://example.com/pagina"))    # -> http://example2.com/pagina

Precaución

Asegúrese de que el formato de page_url sea correcto. Los formatos incorrectos pueden provocar excepciones.

Ejemplo

# Ejemplo de formato de page_url incorrecto causando una excepción
print(linklink.link("//pagina3.com/seccion", "wrong://example.com/pagina")) # -> Exception: [linklink error] invalid page_url format.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

linklink-0.0.0.tar.gz (5.0 kB view hashes)

Uploaded Source

Built Distribution

linklink-0.0.0-py3-none-any.whl (5.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page