# url -- 页面 -- 内容(分析)
import requests
from lxml import html
import math # 页面个数的获取
from book import Book
import xlwt # 用来给excel进行写内容的
'''
补充:
1-添加表头(书名,售价,作者)
2-每一列的宽度进行调整
3-每一行的高度进行调整
4-表头或表内容的字体样式进行设置
'''
# 1-获取页面的代码
def download(url):
# 请求指定的网站,获取响应结果
response = requests.get(url)
# 获取页面的文本--源码
content = response.text # str
# 文本|源码 进行格式化 -- HTMLElement
html_content = html.fromstring(content)
return html_content
# 2-从源码中获取有价值的信息 count=总条目数 num=累计条目数
def getvalues(html_content,count,num):
books_page = [] # 存储指定页码的书籍
# 60 条信息
#list_book = html_content.cssselect('ul.bigimg>li')
list_book = html_content.xpath(
'//ul[@class="bigimg"]/li')
# 检索60