USR_BIN_LINUX Telegram 622
10 забористых примеров использования утилиты curl

В этом посте рассмотрим примеры использования утилиты curl для различных задач.

🔍 Globbing — множественные запросы одной командой:
curl -s "https://jsonplaceholder.example.com/users/[1-3]" | jq -s .

curl -s "https://jsonplaceholder.example.com/users/[0-10:2]" | jq -s .

curl -s "https://jsonplaceholder.example.com/photos/{1,6,35}" | jq -s .

curl -s "https://jsonplaceholder.example.com/users/[1-3]" -o "file_#1.json"


🔍 Использование конфигурационных файлов
Пример конфигурационного файла:
# ~/.curlrc

# some headers
-H "Upgrade-Insecure-Requests: 1"
-H "Accept-Language: en-US,en;q=0.8"

# follow redirects
--location

Пример вызова curl:
curl -K .curlrc https://google.com

Чтобы не палить логины/пароли в истории выполненных команд, можно использовать следующий файл:
# ~/.netrc
machine https://authenticationtest.com/HTTPAuth/
login user
password pass

И вот так вызвать curl:
curl --netrc-file .netrc https://authenticationtest.com/HTTPAuth/


🔍 Параллельные запросы:
curl -I --parallel --parallel-immediate --parallel-max 3 --config websites.txt

curl -I --parallel --parallel-immediate --parallel-max 3 stackoverflow.com google.com example.com


🔍 Форматирование и использование переменных:
curl --silent --output /dev/null --show-error -w @format.txt http://example.com/

# format.txt
Type: %{content_type}\nCode: %{response_code}\n\n

From 8.1.0:\n\n

Scheme: %{url.scheme}\n
Host: %{url.host}\n
Port: %{url.port}\n

Read header content (v7.83.0):\n
%header{date}

Вывод, соответственно, будет таким:
# Type: text/html; charset=UTF-8
# Code: 200
#
# From 8.1.0:
# Scheme: http
# Host: example.com
# Port: 80
#
# Read header content (v7.83.0):
# Server: Sat, 29 Jun 2024 13:01:30 GMT

Полный список переменных по ссылке.

🔍 Тестирование и траблшутинг
Можно выполнять, используя определенный сетевой интерфейс или DNS-сервер:
curl --interface enp5s0 https://example.com

curl --dns-ipv4-addr 1.1.1.1 https://example.com


🔍Использование trurl. Это специализированная утилита, которая позволяет форматировать вывод, например, в формат json:
# Parse as JSON:
./trurl --url "https://example.com/?name=hello" --json
# [
# {
# "url": "https://example.com/?name=hello",
# "parts": {
# "scheme": "https",
# "host": "example.com",
# "path": "/",
# "query": "name=hello"
# },
# "params": [
# {
# "key": "name",
# "value": "hello"
# }
# ]
# }
# ]


Эффективного использования curl!
👍15🔥63



tgoop.com/usr_bin_linux/622
Create:
Last Update:

10 забористых примеров использования утилиты curl

В этом посте рассмотрим примеры использования утилиты curl для различных задач.

🔍 Globbing — множественные запросы одной командой:

curl -s "https://jsonplaceholder.example.com/users/[1-3]" | jq -s .

curl -s "https://jsonplaceholder.example.com/users/[0-10:2]" | jq -s .

curl -s "https://jsonplaceholder.example.com/photos/{1,6,35}" | jq -s .

curl -s "https://jsonplaceholder.example.com/users/[1-3]" -o "file_#1.json"


🔍 Использование конфигурационных файлов
Пример конфигурационного файла:
# ~/.curlrc

# some headers
-H "Upgrade-Insecure-Requests: 1"
-H "Accept-Language: en-US,en;q=0.8"

# follow redirects
--location

Пример вызова curl:
curl -K .curlrc https://google.com

Чтобы не палить логины/пароли в истории выполненных команд, можно использовать следующий файл:
# ~/.netrc
machine https://authenticationtest.com/HTTPAuth/
login user
password pass

И вот так вызвать curl:
curl --netrc-file .netrc https://authenticationtest.com/HTTPAuth/


🔍 Параллельные запросы:
curl -I --parallel --parallel-immediate --parallel-max 3 --config websites.txt

curl -I --parallel --parallel-immediate --parallel-max 3 stackoverflow.com google.com example.com


🔍 Форматирование и использование переменных:
curl --silent --output /dev/null --show-error -w @format.txt http://example.com/

# format.txt
Type: %{content_type}\nCode: %{response_code}\n\n

From 8.1.0:\n\n

Scheme: %{url.scheme}\n
Host: %{url.host}\n
Port: %{url.port}\n

Read header content (v7.83.0):\n
%header{date}

Вывод, соответственно, будет таким:
# Type: text/html; charset=UTF-8
# Code: 200
#
# From 8.1.0:
# Scheme: http
# Host: example.com
# Port: 80
#
# Read header content (v7.83.0):
# Server: Sat, 29 Jun 2024 13:01:30 GMT

Полный список переменных по ссылке.

🔍 Тестирование и траблшутинг
Можно выполнять, используя определенный сетевой интерфейс или DNS-сервер:
curl --interface enp5s0 https://example.com

curl --dns-ipv4-addr 1.1.1.1 https://example.com


🔍Использование trurl. Это специализированная утилита, которая позволяет форматировать вывод, например, в формат json:
# Parse as JSON:
./trurl --url "https://example.com/?name=hello" --json
# [
# {
# "url": "https://example.com/?name=hello",
# "parts": {
# "scheme": "https",
# "host": "example.com",
# "path": "/",
# "query": "name=hello"
# },
# "params": [
# {
# "key": "name",
# "value": "hello"
# }
# ]
# }
# ]


Эффективного использования curl!

BY /usr/bin


Share with your friend now:
tgoop.com/usr_bin_linux/622

View MORE
Open in Telegram


Telegram News

Date: |

Those being doxxed include outgoing Chief Executive Carrie Lam Cheng Yuet-ngor, Chung and police assistant commissioner Joe Chan Tung, who heads police's cyber security and technology crime bureau. How to build a private or public channel on Telegram? How to create a business channel on Telegram? (Tutorial) On Tuesday, some local media outlets included Sing Tao Daily cited sources as saying the Hong Kong government was considering restricting access to Telegram. Privacy Commissioner for Personal Data Ada Chung told to the Legislative Council on Monday that government officials, police and lawmakers remain the targets of “doxxing” despite a privacy law amendment last year that criminalised the malicious disclosure of personal information. Among the requests, the Brazilian electoral Court wanted to know if they could obtain data on the origins of malicious content posted on the platform. According to the TSE, this would enable the authorities to track false content and identify the user responsible for publishing it in the first place.
from us


Telegram /usr/bin
FROM American