编程实现下述功能。
文件ngchina.html保持了网页源代码,请将该页面中图片的URL提取出来,并输出所有图像的URL。
file = open("ngchina.html","r",encoding = \'utf-8\') html_lines = file.readlines() file.close() url_list = [] for line in html_lines: if \'img\' in line: url = line.split(\'src=\')[-1].split(\'"\')[1] if \'http\' in url: url_list.append(url) count = 1 for url in url_list: print("url-{:2}:{}".format(count,url)) count += 1