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)
标签:script,python,BeautifulSoup,soup,获取,html,url1,import 来源: https://www.cnblogs.com/xkdn/p/15456762.html