首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
文件ngchina.htm1保存了网页源代码,请将该页面中图片的URL提取出来,并输出所有图片的URL。输出格式如下: 第1个URL:http://image.ngchina.com.cn/2018/0829/20180829012548753.jpg第2
文件ngchina.htm1保存了网页源代码,请将该页面中图片的URL提取出来,并输出所有图片的URL。输出格式如下: 第1个URL:http://image.ngchina.com.cn/2018/0829/20180829012548753.jpg第2
admin
2019-09-02
32
问题
文件ngchina.htm1保存了网页源代码,请将该页面中图片的URL提取出来,并输出所有图片的URL。输出格式如下:
第1个URL:http://image.ngchina.com.cn/2018/0829/20180829012548753.jpg第2个URL:http://image.ngchina.com.cn/2018/0823/thumb_469_352_20180823121155508.Jpg
选项
答案
参考程序: #读取HTML文件内容 def getHTMLlines(htmlpath): f=open(htmlpath,’’r’’,encoding=’utf一8’) ls=f.readlines() f.close() return ls #用于解析文件并提取图片的URL def extractlmageUrls(htmllist): urls=[] for line in htmllist: if’img’in line: url=line.split(’src=’)[-1].split(’’’’)[1] if’http’in url: urls.append(ur1) return urls #将获取的链接输出到屏幕上 def showResults(urls): count=1 for ur1 in urls: print(’’第{:2}个URL:{}’’.format(count,ur1)) count+=1 #主程序:1读取文件;2解析并提取其中的图片链接;3输出提取结果到屏幕 def main(): inputfile=’’ngchina.html’’ htmllines=getHTMLlines(inputfile) imageUrls=extractImageUrls(htmllines) showResults(imageUrls)
解析
转载请注明原文地址:https://jikaoti.com/ti/0n50FFFM
本试题收录于:
二级Python题库NCRE全国计算机二级分类
0
二级Python
NCRE全国计算机二级
相关试题推荐
在考生文件夹下,有一个学生数据库sdb,打开该数据库,完成如下操作:(1)在学生表student中增加一个名为“照片”的字段,字段数据类型为“通用”。(2)在教师表teacher中建立一个索引名为“教师号”的主索引(升序),索引表达式为教师号。在课程表
(1)使用一对多表单向导新建一个表单sportform。要求:使用“国家”为父表并选择“国家名称”字段作为显示字段,“获奖牌情况”为子表并选择“项目名称”和“名次”字段作为显示字段,使用“国家代码”建立表之间的关系,表单样式选择“阴影式”,按钮类型选择“
在考生文件夹下完成下列操作:(1)用命令新建一个名为“外汇”的数据库,并将该命令存储于one.txt中。(2)将自由表“外汇汇率”、“外汇账户”、“外汇代码”加入到新建的“外汇”数据库中。(3)用SQL语句在“外汇”数据库中新建一个数据库表rate,
(1)打开程序文件progerr.prg,按文件中给出的功能要求改正其中的错误,以文件名prognew.prg重新保存该文件并运行程序。(2)建立顶层表单,表单文件名为myform.scx,表单控件名为myform,表单标题为“顶层表单”。为项层表单建立
在考生文件夹下,打开学生数据库SDB,完成如下简单应用:(1)使用查询设计器设计一个名称为two的查询,查询每个同学的学号(来自student表)、姓名、课程名和成绩。查询结果先按课程名升序、再按成绩降序排序,查询去向是表,表名是two。设计完成后,运行
(1)打开考生文件夹下的数据库SPORT,首先永久删除该数据库中的temp表,然后将“金牌榜”、“获奖牌情况”和“国家”3个自由表加入该数据库中。(2)在表设计器中,为表“金牌榜”建立_个普通索引,索引名和索引表达式均为“金牌数”。(3)使用SQL语句
(1)建立数据库ordersmanage.dbc。把自由表employee.dbf和orders.dbf添加到数据库中。(2)打开表单dh.scx,设置标签控件中英文字母的字号为18,保存表单。(3)打开表单dh.scx,为命令按钮“隐藏"添加代码,使
下面对视图的描述中错误的是
下列函数返回类型为数值型的是()。
在VisualFoxPro中,有如下程序,函数IIF()返回值是()。*程序PRIVATEX,YSTORE"男"TOXY=LEN(X)+2?IIF(Y
随机试题
1919年英国率先颁布了
急性肾衰竭禁止摄入蛋白质的时间是少尿期开始的
世界卫生组织首次主持修订ICD的时间是
在药品的标签或说明书上,哪些文字和标志是不必要的
青年男性。2天来胸背部疼痛,今晨出现双下肢无力,伴二便障碍,查脐以下各种感觉障碍,双下肢肌力0级,无病理反射。最可能的诊断是
以下四种建筑中常用岩石的主要造岩矿物,何者既坚固、耐久,又韧性大、开光性好?[2000年第004题]
基坑支护破坏的主要形式有()引起的破坏。
读图完成下列问题:图中山坡E和山坡F的坡度相比,坡度陡的是_______。
Itisrecommendedthattheproject______(所有的准备工作结束之后再开始).
A、Gotosummerschool.B、Takeavacation.C、Stayathome.D、Earnsomemoney.D
最新回复
(
0
)