python获取script里的内容

Posted Darcy

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python获取script里的内容相关的知识,希望对你有一定的参考价值。

import requests
from bs4 import BeautifulSoup

url1 = "https://mip.keoaeic.org/journal_skills/6616.html"
html = requests.get(url1).content
html=html.decode(‘utf-8‘) # python3
soup = BeautifulSoup(html, "html.parser")
a = soup.select(‘script[type="application/ld+json"]‘) 
#查找<script[type="application/ld+json"]> 里面的内容,因为这个地址上面有多个相同的,只需要获取对应的下标内容即可。

t = list(a)[0].text
print(r)

  

以上是关于python获取script里的内容的主要内容,如果未能解决你的问题,请参考以下文章