我正在处理一个包含大约10亿个不同网站的数据库。问题是它包含了各种不同的拼写:
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}'
来获得有效的网址,结果是有希望的。
我注意到的一些问题:
1.有些域可能有curl无法解析的基于JS的重定向。太少了。
1.当http和https协议都可用时,它返回http一。将https优先化会很好。
1.非域字符串也会被解析,例如curl notadomain -s -L -I -o /dev/null -w '%{url_effective}'
〉http://notadomain/
。如果curl在这种情况下抛出错误会更好。
如何解决以上问题?尤其是最后一个问题。
这个解决方案还有什么我现在看不到的缺点吗?
我的另一个想法是解析每个域后面的服务器IP。
1条答案
按热度按时间gtlvzcf81#
这个解决方案还有什么我现在看不到的缺点吗?
如果不知道你在做什么,为什么要这么做,我就不能很好地回答这个问题。
curl不需要抛出错误。
但它确实给予了你足够的信息,让你自己做出决定。
这些是返回的curl值。
这些是重定向到HTTPS的HTTP请求的典型值
这与没有DNS的url完全不同