标签:find get for XML view sub 网页 tle 代码
from bs4 import BeautifulSoup
import requests
#获取爬去的网址
url=requests.get(‘https://movie.douban.com/subject/24773958/‘)
#获取网页源代码
v_source=BeautifulSoup(url.text,‘lxml‘)
# print(v_source)
# 爬取标题
v_title=v_source.find(‘span‘,attrs={‘property‘:‘v:itemreviewed‘})
#print(v_title.text)
v_jianjie=v_source.find(‘span‘,attrs={‘property‘:‘v:summary‘})
print(v_jianjie.text)
v_leixing=v_source.find_all(‘span‘,attrs={‘property‘:‘v:genre‘})
# for i in range(len(v_leixing)):
# print(v_leixing[i].text,end=‘ ‘)
for i in v_leixing:
print(i.text)
标签:find get for XML view sub 网页 tle 代码
原文地址:https://www.cnblogs.com/inorilzy/p/9569300.html