请在 下方输入 要搜索的题目:

1、网页html代码如下:<html> <head> <title> This is a python demo page </title> </head> <body> <p> <b> The demo python introduces several python courses. </b> </p> <p> Python is a wonderful general-purpose programming language. You can learn Python from novice to professional by tracking the following courses: <a href="http://www.icourse163.org/course/BIT-268001" id="link1"> Basic Python </a> and <a href="http://www.icourse163.org/course/BIT-1001870001" id="link2"> Advanced Python </a> . </p> </body></html> (1)分析下面代码,补全代码。(6分) #引入bs4 #引入requests库import requests#爬取页面,将返回时封装到rr=requests.get("http://python123.io/ws/demo.html")#获取页面html信息demo=r.text#使用BeautifulSoup加载html print(soup.head) #结果1print(soup.head.contents) #结果2print(soup.title.parent) #结果3for parent in soup.a.parents: #结果4 if parent is None: print(parent) else: print(parent.name)print(soup.a.next_sibling) #结果5

1、网页html代码如下: This is a python demo page

The demo python introduces several python courses.

Python is a wonderful general-purpose programming language. You can learn Python from novice to professional by tracking the following courses: Basic Python and Advanced Python .

(1)分析下面代码,补全代码。(6分) #引入bs4 #引入requests库import requests#爬取页面,将返回时封装到rr=requests.get("http://python123.io/ws/demo.html")#获取页面html信息demo=r.text#使用BeautifulSoup加载html print(soup.head) #结果1print(soup.head.contents) #结果2print(soup.title.parent) #结果3for parent in soup.a.parents: #结果4 if parent is None: print(parent) else: print(parent.name)print(soup.a.next_sibling) #结果5

发布时间:2024-09-05 17:22:52
推荐参考答案 ( 由 搜搜题库网 官方老师解答 )
联系客服
答案:

关于我们 免责声明 联系我们 联系在线客服 今日最新试题

声明:本站所有素材/文章除标明原创外,均来自网络转载,版权归原作者所有,如果有侵犯到您的权益,请联系本站删除,谢谢合作!

copyright © 2023 搜搜题 all rights reserved. 晋ICP备2024044554号-1

友情链接:青播