加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Python > 正文

python – 使用BeautifulSoup提取

发布时间:2020-12-16 22:18:23 所属栏目:Python 来源:网络整理
导读:1 /我正在尝试使用美丽的汤提取脚本的一部分,但它打印无.怎么了 ? URL = "http://www.reuters.com/video/2014/08/30/woman-who-drank-restaurants-tainted-tea?videoId=341712453"oururl= urllib2.urlopen(URL).read()soup = BeautifulSoup(oururl)for scri

1 /我正在尝试使用美丽的汤提取脚本的一部分,但它打印无.怎么了 ?

URL = "http://www.reuters.com/video/2014/08/30/woman-who-drank-restaurants-tainted-tea?videoId=341712453"
oururl= urllib2.urlopen(URL).read()
soup = BeautifulSoup(oururl)

for script in soup("script"):
        script.extract()

list_of_scripts = soup.findAll("script")
print list_of_scripts

2 /目标是提取属性“transcript”的值: