УРЛов может быть 20к. Сайты разные.
ЦитироватьКак массово проверить коды ответа сервера и время загрузки страниц?
Интересная задачка :)
Коды ответов получить достаточно просто. А вот время загрузки страниц... Могу предложить такой вариант:
#!/bin/bash
read -p "Список URL ": list
xargs -n1 -P 10 curl -o /dev/null --silent --head --write-out '%{url_effective};%{http_code};%{time_total};%{speed_download}\n' < $list | tee results.csv
Здесь - "многопоточный" запуск curl (выполняется 10 процессов одновременно -P 10). В качестве источника данных - файл, содержащий список URL (при запуске скрипта выводится запрос на ввод названия этого файла). Результат работы сохраняется в файл results.csv
Какие данный собираются...
В данном случае, это собственно сам URL и для него - код ответа, общее время выполнения в секундах, средняя скорость до окончания полной загрузки через curl.
"Собираемые" данные прописываюся в виде %{variable_name}. Могут использоваться следующие переменные:
[spoiler]
# content_type The Content-Type of the requested document, if
# there was any.
#
# filename_effective
# The ultimate filename that curl writes out to.
# This is only meaningful if curl is told to write
# to a file with the -O, --remote-name or -o,
# --output option. It's most useful in combination
# with the -J, --remote-header-name option. (Added
# in 7.26.0)
#
# ftp_entry_path The initial path curl ended up in when logging on
# to the remote FTP server. (Added in 7.15.4)
#
# http_code The numerical response code that was found in the
# last retrieved HTTP(S) or FTP(s) transfer. In
# 7.18.2 the alias response_code was added to show
# the same info.
#
# http_connect The numerical code that was found in the last
# response (from a proxy) to a curl CONNECT
# request. (Added in 7.12.4)
#
# http_version The http version that was effectively used.
# (Added in 7.50.0)
#
# local_ip The IP address of the local end of the most
# recently done connection - can be either IPv4 or
# IPv6 (Added in 7.29.0)
#
# local_port The local port number of the most recently done
# connection (Added in 7.29.0)
#
# num_connects Number of new connects made in the recent trans-
# fer. (Added in 7.12.3)
#
# num_redirects Number of redirects that were followed in the
# request. (Added in 7.12.3)
#
# redirect_url When an HTTP request was made without -L to fol-
# low redirects, this variable will show the actual
# URL a redirect would take you to. (Added in
# 7.18.2)
#
# remote_ip The remote IP address of the most recently done
# connection - can be either IPv4 or IPv6 (Added in
# 7.29.0)
#
# remote_port The remote port number of the most recently done
# connection (Added in 7.29.0)
#
# scheme The URL scheme (sometimes called protocol) that
# was effectively used (Added in 7.52.0)
#
# size_download The total amount of bytes that were downloaded.
#
# size_header The total amount of bytes of the downloaded head-
# ers.
#
# size_request The total amount of bytes that were sent in the
# HTTP request.
#
# size_upload The total amount of bytes that were uploaded.
#
# speed_download The average download speed that curl measured for
# the complete download. Bytes per second.
#
# speed_upload The average upload speed that curl measured for
# the complete upload. Bytes per second.
#
# ssl_verify_result
# The result of the SSL peer certificate verifica-
# tion that was requested. 0 means the verification
# was successful. (Added in 7.19.0)
#
# time_appconnect
# The time, in seconds, it took from the start
# until the SSL/SSH/etc connect/handshake to the
# remote host was completed. (Added in 7.19.0)
#
# time_connect The time, in seconds, it took from the start
# until the TCP connect to the remote host (or
# proxy) was completed.
#
# time_namelookup
# The time, in seconds, it took from the start
# until the name resolving was completed.
#
# time_pretransfer
# The time, in seconds, it took from the start
# until the file transfer was just about to begin.
# This includes all pre-transfer commands and nego-
# tiations that are specific to the particular pro-
# tocol(s) involved.
#
# time_redirect The time, in seconds, it took for all redirection
# steps include name lookup, connect, pretransfer
# and transfer before the final transaction was
# started. time_redirect shows the complete execu-
# tion time for multiple redirections. (Added in
# 7.12.3)
#
# time_starttransfer
# The time, in seconds, it took from the start
# until the first byte was just about to be trans-
# ferred. This includes time_pretransfer and also
# the time the server needed to calculate the
# result.
#
# time_total The total time, in seconds, that the full opera-
# tion lasted. The time will be displayed with mil-
# lisecond resolution.
#
# url_effective The URL that was fetched last. This is most mean-
# ingful if you've told curl to follow location:
# headers.
[/spoiler]
P.S. Нужен установленный curl.
P.P.S. Если хотя бы частично решит задачу, буду рад.
Цитата: Val_Ery от 23-03-2020, 21:35:05А вот время загрузки страниц
Это время загрузки страниц в браузере?
По установке, видимо придется обращаться в саппорт ВДС. Сам я не программист и не админ. )
Цитата: vold57 от 23-03-2020, 22:04:52
Это время загрузки страниц в браузере?
К сожалению, нет. Curl - он, как бы, текстовый. То есть, можно в консоли просто набрать
curl http://vold57.com
и любоваться разметкой в терминале.
Временные "отсечки" касаются только того, что сервер отдаёт curl'у по его запросу.
В общем, я пока не придумал, как с-имитировать погрузку линка, как это делает браузер, и с помощью чего проще посчитать время для каждого конкретного линка. Придумаю - отпишусь...
P. S. Про vds. Если скажете, какая там ось установлена (у Вас ведь есть права админа?), подскажу, как установить. Ну... Это, если решитесь попробовать ;)
Вообще, curl можно поставить и на вин10. Нужно только задействовать подсистемы виндовс для линукс и установить нормальный (в отличии от cmd или powers hell) линуксовый терминал
Коды ответа сервера покажет какая-нибудь програмулина типа Netpeak spider, ксеня тоже вроде может
А скорость, если сайт шаблонный типа вп, джумлы, dle, будет на всех страницах примерно одинаковой, т.к. по шаблону подключаются одни и те же css и js файлы. Ну да, могут отдельные страницы весить больше из-за тяжелых фоток. Это можно посмотреть по website auditor в разделе "слишком большие страницы". Здесь на форуме вроде была тема по бесплатному анализу сайта в wsa
Цитата: alexakap от 24-03-2020, 13:11:48А скорость, если сайт шаблонный типа вп, джумлы, dle, будет на всех страницах примерно одинаковой
Цитата: vold57 от 22-03-2020, 22:21:45УРЛов может быть 20к. Сайты разные.