# -*- encoding:utf-8 -*-
from bs4 import BeautifulSoup
import urllib
import urllib.request
import re
Url = 'https://book.douban.com/latest?icn=index-latestbook-all'
page = urllib.request.urlopen(Url).read().decode('utf-8')
soup = BeautifulSoup(page, 'html.parser')
#class标识CSS类名的关键字 class 在Python中是保留字,使用 class 做参数会导致语法错误.
# 从Beautiful Soup的4.1.1版本开始,可以通过 class_ 参数搜索有指定CSS类名的tag
books = soup.find_all('div', class_='detail-frame')
for item in books:
print(item.find('h2').contents[0])
constracts = item.find_all('p');
for item2 in constracts:
print(item2.contents[0])
print('*********************************')