python獲取script里的內容


import requests
from bs4 import BeautifulSoup
 
url1 = "https://www.zzlian.com/33.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)

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM