Skip to main content

this is flarebrow package

Project description

flaretool

flaretool is flarebrow Library.

python Downloads

API Doc

Attention

This library is under development and may exhibit unexpected behavior. New features will be released soon. Please stay tuned.

install

pip install flaretool

NetTool usage

NetTool Usage Document

NetTool Examples of usage

from flaretool import nettool

# 指定されたIPアドレスの情報を取得する例
ip_info = nettool.get_global_ipaddr_info("192.168.0.1")
print("ip:", ip_info.ipaddr)
print("hostname:", ip_info.hostname)
print("country:", ip_info.country)
# 出力例:
# ip: 192.168.0.1
# hostname: sample.com
# country: earth

# ドメイン名からIPアドレスを取得する例
ip_address = nettool.lookup_ip("example.com")
print(ip_address)  # 123.456.789.001

# IPアドレスからドメイン名を取得する例
domain_name = nettool.lookup_domain("1.1.1.1")
print(domain_name)  # one.one.one.one

# 指定されたIPアドレスが指定されたネットワークに属しているかどうかを判定する例
allowed_networks = ["192.168.0.0/24", "10.0.0.0/16"]
is_allowed = nettool.is_ip_in_allowed_networks(
    "192.168.0.100", allowed_networks)
print(is_allowed)  # True

# 指定されたドメイン名が存在するかどうかを判定する例
domain_exists = nettool.domain_exists("example.com")
print(domain_exists)  # True

# 日本のIPアドレスのリストを取得する例
japan_ips = nettool.get_japanip_list()
print(japan_ips)

# 指定されたアドレスが日本のIPアドレスか確認する例
is_japan = nettool.is_japan_ip("203.0.113.1")
print(is_japan)  # False

# 日本語を含むドメインをpunycodeに変換する例
puny_info = nettool.get_puny_code("日本語ドメイン.jp")
print("originalvalue:", puny_info.originalvalue)
print("encodevalue:", puny_info.encodevalue)
print("decodevalue:", puny_info.decodevalue)
# 出力例:
# originalvalue: 日本語ドメイン.jp
# encodevalue: xn--eckwd4c7c5976acvb2w6i.jp
# decodevalue: 日本語ドメイン.jp

# 特定のユーザーエージェントでスクレイピング可否を確認する例
url = "http://example.com/page.html"
user_agent = "MyScraperBot"
allowed = nettool.is_scraping_allowed(url, user_agent) # user_agentはオプション引数
if allowed:
    print(f"{url} はユーザーエージェント '{user_agent}' でのスクレイピングが許可されています。")
else:
    print(f"{url} はユーザーエージェント '{user_agent}' でのスクレイピングが禁止されています。")

NetTool Command Examples of usage

flaretool nettool get_global_ipaddr_info
# usage
# flaretool nettool {FunctionName} [args...]

All methods within Netttol can be executed as commands.

Help Command

flaretool nettool -h

JapaneseHoliday Examples of usage

Holiday Usage Document

from flaretool.holiday import JapaneseHolidays
import datetime

# JapaneseHolidaysクラスのインスタンスを作成
holidays = JapaneseHolidays()

# 特定の日付が祝日かどうかを判定
date = datetime.date(2023, 1, 1)
is_holiday = holidays.get_holiday_name(date)
print(is_holiday)  # "元日" が出力される

# 特定の期間内の祝日一覧を取得
start_date = datetime.date(2023, 1, 1)
end_date = datetime.date(2023, 12, 31)
holiday_list = holidays.get_holidays_in_range(start_date, end_date)
for holiday in holiday_list:
    print(holiday)
# 出力例:
# ("元日", datetime.date(2023, 1, 1))
# ("元日(振替休日)", datetime.date(2023, 1, 2))
# ("成人の日", datetime.date(2023, 1, 9))
# ("建国記念の日", datetime.date(2023, 2, 11))
# ...

# 特定期間内の営業日のリストを取得
business_days = holidays.get_business_date_range(start_date, end_date)
for business_day in business_days:
    print(business_day)
# 出力例:
# 2023-01-03
# 2023-01-04
# 2023-01-05
# ...

Flarebrow Service

There are the following services available:

  1. Short URL service: This service allows you to shorten URLs.
  2. DDNS (Dynamic DNS) service: This service provides Dynamic DNS functionality.

To use this class, you need to set up an API key.

Configuration API Key

The library you are using relies on an API key to communicate with an external service. To securely store the API key, it needs to be defined either as an environment variable or in a .env file or script setting. Please follow the instructions below:

Using an script setting:

import flaretool
flaretool.api_key = "your_api_key_here"

Using an environment variable:

Set the API key as an environment variable using the following variable name:

  • API_KEY

Example of defining an environment variable (Linux/macOS):

export API_KEY=your_api_key_here

Example of defining an environment variable (Windows):

set API_KEY=your_api_key_here

Using a .env file:

Create a .env file in the root directory of your project and define the API key as follows:

API_KEY=your_api_key_here

The library will read the API key from the .env file.

You need to log in to the external service's account to obtain an API key. Be careful not to share your API key with others, and avoid committing the .env file to a public version control system.

Please refer to the documentation of the library you are using to find the specific instructions for setting the API key and the exact name of the environment variable.

ShortURL Service Usage

from flaretool.shorturl import ShortUrlService
shorturl = ShortUrlService()

# 新規登録
result = shorturl.create_short_url("https://example.com")
print("ShortLink:", result.link)   # https://○○○/○○○
print("OriginalURL:", result.url)  # https://example.com

# 情報取得
result = shorturl.get_short_url_info(result.id)[0]
print("ShortLink:", result.link)   # https://○○○/○○○
print("OriginalURL:", result.url)  # https://example.com

# 更新
result.url = "https://example.com/sample"
result = shorturl.update_short_url(result)
print("ShortLink:", result.link)   # https://○○○/○○○
print("OriginalURL:", result.url)  # https://example.com/sample

# 削除
shorturl.delete_short_url(result)

DDNS Service Usage

from flaretool.ddns import DdnsService
service = DdnsService()
info = service.update_ddns("example", "192.168.0.100")
print(info.status)    # successful
print(info.currentIp) # 192.168.0.99
print(info.updateIp)  # 192.168.0.100
print(info.domain)    # example.○○○.○○

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

flaretool-0.1.23.tar.gz (19.4 kB view hashes)

Uploaded Source

Built Distribution

flaretool-0.1.23-py3-none-any.whl (22.4 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