怎么使用beautifulsoup获取指定div标签内容
1个回答
展开全部
f = urllib2.urlopen(url)
req = f.read()
soup = BeautifulSoup(req)
content = soup.findAll(attrs={"name":"readonlycounter2"})
subId = content[0].string.split(',')[1]
subName = soup.html.body.h1.span.string
content = soup.findAll(attrs={"class":"subdes_td"})
subType = content[0].string
subLeg = content[1].string
content = soup.findAll(attrs={"colspan":"3"})
subTime = content[2].string
subFile = content[7].div.string
req = f.read()
soup = BeautifulSoup(req)
content = soup.findAll(attrs={"name":"readonlycounter2"})
subId = content[0].string.split(',')[1]
subName = soup.html.body.h1.span.string
content = soup.findAll(attrs={"class":"subdes_td"})
subType = content[0].string
subLeg = content[1].string
content = soup.findAll(attrs={"colspan":"3"})
subTime = content[2].string
subFile = content[7].div.string
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询