Define extract_links function.