jingpengzhang

编程实现下述功能。

文件ngchina.html保持了网页源代码,请将该页面中图片的URL提取出来,并输出所有图像的URL。

ngchina.html下载

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

    

 

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2021-07-01
  • 2022-12-23
  • 2022-12-23
  • 2022-01-18
  • 2022-02-21
  • 2021-11-23
猜你喜欢
  • 2022-12-23
  • 2021-10-15
  • 2021-12-09
  • 2021-12-20
  • 2021-09-15
  • 2022-02-09
相关资源
相似解决方案