库以查找URL并检查其有效性。
urlfinderlib的Python项目详细描述
#urlfinderlib python库,用于查找文档和任意数据中的url并检查其有效性。
基本用法
from urlfinderlib import find_urls
- with open(‘/path/to/file’, ‘rb’) as f:
- print(find_urls(f.read())
base_url用法
如果您试图在html文件中找到url,那么url中的路径可能与它们在承载html的服务器上的位置有关。在本例中,可以使用base_url参数提取这些“相对”url。
from urlfinderlib import find_urls
- with open(‘/path/to/file’, ‘rb’) as f:
- print(find_urls(f.read(), base_url=’http://somewebsite.com/’)