-- coding: utf-8 --
“”"
Created on Sat Feb 29 19:13:37 2020
@author: acliu
“”"
#获取房屋的基本信息(若干页)
#贝壳二手房北京房价
#https://bj.ke.com/ershoufang/
# -*- coding: utf-8 -*-
"""
Created on Sun Mar 1 19:12:53 2020
@author: acliu
"""
import xlwt
import requests
from bs4 import BeautifulSoup
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.122 Safari/537.36',\
"Host": "bj.ke.com",
}
# 将获取的信息保存到表格中
def save_info(content):
workbook = xlwt.Workbook(encoding = 'ascii')
worksheet = workbook.add_sheet('house info')
style = xlwt.XFStyle() # 初始化样式
font = xlwt.Font() # 为样式创建字体
font.name = 'Times New Roman'
font.bold = True # 黑体
font.underline = True # 下划线
font.italic = True # 斜体字
style.font = font # 设定样式
worksheet.write(0, 0, '名称')
worksheet.