我正在處理一個包含大約十億個不同網站的資料庫。問題是它包含各種不同的拼寫:
example.com
subdomain.example.com
http://example.com
https://example.com
https://example.com/
https://sub.example.com
...
此外,一些域已經過時并且具有永久重定向。
我該如何清理這個爛攤子?
我curl {domain} -s -L -I -o /dev/null -w '%{url_effective}'用來獲取有效的網址,結果很有希望。
我注意到的一些問題:
- 某些域可能具有 curl 無法決議的基于 JS 的重定向。太少打擾了。
- 當 http 和 https 協議都可用時,它回傳 http 一個。優先考慮https會很好。
- 非域字串也正在決議中,例如
curl notadomain -s -L -I -o /dev/null -w '%{url_effective}'>http://notadomain/。如果 curl 在這種情況下拋出錯誤會更好。
我該如何解決以上問題?尤其是最后一個。
這個解決方案還有我現在看不到的其他缺點嗎?
我的另一個想法是決議每個域后面的服務器 ip。
uj5u.com熱心網友回復:
這個解決方案還有我現在看不到的其他缺點嗎?
如果不知道您這樣做是什么以及為什么要這樣做,就無法很好地回答這個問題。
curl 不需要拋出錯誤。
但它確實為您提供了足夠的資訊來自己做出決定。
這些是回傳的 curl 值。
content_type
http_code
header_size
request_size
filetime
ssl_verify_result
redirect_count
total_time
namelookup_time
connect_time
pretransfer_time
size_upload
size_download
speed_download
speed_upload
download_content_length
upload_content_length
starttransfer_time
redirect_time
redirect_url
primary_ip
certinfo
request_header
response_headers
這些是重定向到 HTTPS 的 HTTP 請求的典型值
content_type = text/html; charset=UTF-8
http_code = 200
header_size = 342
request_size = 98
filetime = -1
ssl_verify_result = 20
redirect_count = 1
total_time = 0.202927
namelookup_time = 0.000971
connect_time = 0.059346
pretransfer_time = 0.094196
size_upload = 0.0
size_download = 4753.0
speed_download = 23422.0
speed_upload = 0.0
download_content_length = -1.0
upload_content_length = 0.0
starttransfer_time = 0.199499
redirect_time = 0.060231
redirect_url =
primary_ip = 99.999.999.999
certinfo = primary_port = 443, local_ip = 88.888.888.888, local_port = 55530,
HTTP/1.1 301 Moved Permanently
Date: Fri, 21 Oct 2022 00:44:18 GMT
Server: Apache
Location: https://example.com/
Content-Length: 227
Content-Type: text/html; charset=iso-8859-1
HTTP/1.1 200 OK
Date: Fri, 21 Oct 2022 00:44:18 GMT
Server: Apache
Vary: User-Agent
Transfer-Encoding: chunked
Content-Type: text/html; charset=UTF-8
這與沒有 DNS 的 url 完全不同
content_type = NULL
http_code = 0
header_size = 0
request_size = 0
filetime = -1
ssl_verify_result = 0
redirect_count = 0
total_time = 0.221879
namelookup_time = 0.0
connect_time = 0.0
pretransfer_time = 0.0
size_upload = 0.0
size_download = 0.0
speed_download = 0.0
speed_upload = 0.0
download_content_length = -1.0
upload_content_length = -1.0
starttransfer_time = 0.0
redirect_time = 0.0
redirect_url =
primary_ip =
certinfo = primary_port = 0, local_ip = , local_port = 0
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/521086.html
標籤:卷曲dns
