爬取时间:2020年4月30日
一、结果
| 网址 | 城市 | 二手房数量 |
| https://bj.lianjia.com/ | 北京 | 89386 |
| https://sh.lianjia.com/ | 上海 | 59926 |
| https://sz.lianjia.com/ | 深圳 | 42959 |
| https://aq.lianjia.com/ | 安庆 | 13962 |
| https://cz.fang.lianjia.com/ | 滁州 | 0 |
| https://hf.lianjia.com/ | 合肥 | 65502 |
| https://mas.lianjia.com/ | 马鞍山 | 10942 |
| https://wuhu.lianjia.com/ | 芜湖 | 22003 |
| https://bj.lianjia.com/ | 北京 | 89386 |
| https://cq.lianjia.com/ | 重庆 | 148487 |
| https://fz.lianjia.com/ | 福州 | 17500 |
| https://quanzhou.lianjia.com/ | 泉州 | 14157 |
| https://xm.lianjia.com/ | 厦门 | 28832 |
| https://zhangzhou.lianjia.com/ | 漳州 | 18939 |
| https://dg.lianjia.com/ | 东莞 | 22206 |
| https://fs.lianjia.com/ | 佛山 | 35799 |
| https://gz.lianjia.com/ | 广州 | 69833 |
| https://hui.lianjia.com/ | 惠州 | 34427 |
| https://jiangmen.lianjia.com/ | 江门 | 6813 |
| https://qy.lianjia.com/ | 清远 | 7658 |
| https://sz.lianjia.com/ | 深圳 | 42959 |
| https://zh.lianjia.com/ | 珠海 | 20681 |
| https://zhanjiang.lianjia.com/ | 湛江 | 5005 |
| https://zs.lianjia.com/ | 中山 | 31759 |
| https://gy.lianjia.com/ | 贵阳 | 25343 |
| https://bh.lianjia.com/ | 北海 | 18182 |
| https://fcg.lianjia.com/ | 防城港 | 4599 |
| https://gl.lianjia.com/ | 桂林 | 14045 |
| https://liuzhou.lianjia.com/ | 柳州 | 6329 |
| https://nn.lianjia.com/ | 南宁 | 13849 |
| https://lz.lianjia.com/ | 兰州 | 15102 |
| https://ez.lianjia.com/ | 鄂州 | 2984 |
| https://huangshi.lianjia.com/ | 黄石 | 6336 |
| https://wh.lianjia.com/ | 武汉 | 55692 |
| https://xy.lianjia.com/ | 襄阳 | 9852 |
| https://yichang.lianjia.com/ | 宜昌 | 10903 |
| https://cs.lianjia.com/ | 长沙 | 29550 |
| https://changde.lianjia.com/ | 常德 | 4353 |
| https://yy.lianjia.com/ | 岳阳 | 2884 |
| https://zhuzhou.lianjia.com/ | 株洲 | 7423 |
| https://bd.lianjia.com/ | 保定 | 12910 |
| https://lf.lianjia.com/ | 廊坊 | 20809 |
| https://qhd.fang.lianjia.com/ | 秦皇岛 | 0 |
| https://sjz.lianjia.com/ | 石家庄 | 25926 |
| https://ts.lianjia.com/ | 唐山 | 15277 |
| https://zjk.lianjia.com/ | 张家口 | 21330 |
| https://bt.fang.lianjia.com/ | 保亭 | 0 |
| https://cm.fang.lianjia.com/ | 澄迈 | 0 |
| https://dz.fang.lianjia.com/ | 儋州 | 0 |
| https://hk.lianjia.com/ | 海口 | 4868 |
| https://lg.fang.lianjia.com/ | 临高 | 0 |
| https://ld.fang.lianjia.com/ | 乐东 | 0 |
| https://ls.fang.lianjia.com/ | 陵水 | 0 |
| https://qh.fang.lianjia.com/ | 琼海 | 0 |
| https://san.lianjia.com/ | 三亚 | 1136 |
| https://wzs.fang.lianjia.com/ | 五指山 | 0 |
| https://wc.fang.lianjia.com/ | 文昌 | 0 |
| https://wn.fang.lianjia.com/ | 万宁 | 0 |
| https://kf.lianjia.com/ | 开封 | 8124 |
| https://luoyang.lianjia.com/ | 洛阳 | 13835 |
| https://smx.fang.lianjia.com/ | 三门峡 | 0 |
| https://xinxiang.lianjia.com/ | 新乡 | 9483 |
| https://xc.lianjia.com/ | 许昌 | 9993 |
| https://zz.lianjia.com/ | 郑州 | 107945 |
| https://zk.lianjia.com/ | 周口 | 7957 |
| https://zmd.lianjia.com/ | 驻马店 | 6062 |
| https://hrb.lianjia.com/ | 哈尔滨 | 73431 |
| https://changzhou.lianjia.com/ | 常州 | 18554 |
| https://haimen.lianjia.com/ | 海门 | 2662 |
| https://ha.lianjia.com/ | 淮安 | 16889 |
| https://jy.lianjia.com/ | 江阴 | 2268 |
| https://ks.lianjia.com/ | 昆山 | 17902 |
| https://nj.lianjia.com/ | 南京 | 85860 |
| https://nt.lianjia.com/ | 南通 | 35836 |
| https://su.lianjia.com/ | 苏州 | 72463 |
| https://wx.lianjia.com/ | 无锡 | 32399 |
| https://xz.lianjia.com/ | 徐州 | 21062 |
| https://yc.lianjia.com/ | 盐城 | 12694 |
| https://zj.lianjia.com/ | 镇江 | 22089 |
| https://cc.lianjia.com/ | 长春 | 53982 |
| https://jl.lianjia.com/ | 吉林 | 13250 |
| https://ganzhou.lianjia.com/ | 赣州 | 11844 |
| https://jiujiang.lianjia.com/ | 九江 | 12326 |
| https://jian.lianjia.com/ | 吉安 | 10016 |
| https://nc.lianjia.com/ | 南昌 | 55656 |
| https://sr.lianjia.com/ | 上饶 | 9186 |
| https://dl.lianjia.com/ | 大连 | 89538 |
| https://dd.lianjia.com/ | 丹东 | 9612 |
| https://sy.lianjia.com/ | 沈阳 | 103216 |
| https://baotou.lianjia.com/ | 包头 | 16173 |
| https://cf.lianjia.com/ | 赤峰 | 16835 |
| https://hhht.lianjia.com/ | 呼和浩特 | 24801 |
| https://yinchuan.lianjia.com/ | 银川 | 15953 |
| https://sh.lianjia.com/ | 上海 | 59916 |
| https://bz.lianjia.com/ | 巴中 | 1224 |
| https://cd.lianjia.com/ | 成都 | 136808 |
| https://dy.lianjia.com/ | 德阳 | 4753 |
| https://dazhou.lianjia.com/ | 达州 | 6420 |
| https://leshan.fang.lianjia.com/ | 乐山 | 0 |
| https://liangshan.lianjia.com/ | 凉山 | 3039 |
| https://mianyang.lianjia.com/ | 绵阳 | 14460 |
| https://ms.fang.lianjia.com/ | 眉山 | 0 |
| https://nanchong.lianjia.com/ | 南充 | 11333 |
| https://sn.lianjia.com/ | 遂宁 | 5166 |
| https://yibin.lianjia.com/ | 宜宾 | 4850 |
| https://heze.lianjia.com/ | 菏泽 | 4208 |
| https://jn.lianjia.com/ | 济南 | 49436 |
| https://jining.lianjia.com/ | 济宁 | 9386 |
| https://linyi.lianjia.com/ | 临沂 | 16541 |
| https://qd.lianjia.com/ | 青岛 | 74981 |
| https://ta.lianjia.com/ | 泰安 | 5117 |
| https://wf.lianjia.com/ | 潍坊 | 21349 |
| https://weihai.lianjia.com/ | 威海 | 15698 |
| https://yt.lianjia.com/ | 烟台 | 33485 |
| https://zb.lianjia.com/ | 淄博 | 17712 |
| https://baoji.lianjia.com/ | 宝鸡 | 4709 |
| https://hanzhong.lianjia.com/ | 汉中 | 5040 |
| https://xa.lianjia.com/ | 西安 | 86485 |
| https://xianyang.lianjia.com/ | 咸阳 | 7567 |
| https://jz.lianjia.com/ | 晋中 | 1338 |
| https://ty.lianjia.com/ | 太原 | 20779 |
| https://tj.lianjia.com/ | 天津 | 121614 |
| https://dali.lianjia.com/ | 大理 | 4842 |
| https://km.lianjia.com/ | 昆明 | 33388 |
| https://xsbn.fang.lianjia.com/ | 西双版纳 | 0 |
| https://hz.lianjia.com/ | 杭州 | 66030 |
| https://huzhou.lianjia.com/ | 湖州 | 9086 |
| https://jx.lianjia.com/ | 嘉兴 | 32957 |
| https://jh.lianjia.com/ | 金华 | 10609 |
| https://nb.lianjia.com/ | 宁波 | 30286 |
| https://quzhou.lianjia.com/ | 衢州 | 2907 |
| https://sx.lianjia.com/ | 绍兴 | 18665 |
| https://taizhou.lianjia.com/ | 台州 | 7157 |
| https://wz.lianjia.com/ | 温州 | 16598 |
| https://yw.lianjia.com/ | 义乌 | 2143 |
二、代码
import requests
import re
import time
import xlrd
import xlwt
from xlutils.copy import copy
def get_house_quantity(url):
#获取二手房数量
url = url + "ershoufang/"
html = requests.get(url)
html = html.text
pat = '
<h2 class="total fl">共找到<span>(.*?)</span>.*?</h2>
'
result = re.findall(pat,html)
if len(result) == 0:
house_quantity = 0
else:
house_quantity = result[0]
return house_quantity
def get_city_list(url):
#获取城市列表,返回的是一个城市列表,每一个数据为 ('https://wz.lianjia.com/', '温州')
html = requests.get(url).text
pat = '
<li><a href="(.*?)">(.*?)</a></li>
'
result = re.findall(pat,html)
return result
def write_excel_xls_append(path, value):
workbook = xlrd.open_workbook(path) # 打开工作簿
sheets = workbook.sheet_names() # 获取工作簿中的所有表格
worksheet = workbook.sheet_by_name(sheets[0]) # 获取工作簿中所有表格中的的第一个表格
rows_old = worksheet.nrows # 获取表格中已存在的数据的行数
new_workbook = copy(workbook) # 将xlrd对象拷贝转化为xlwt对象
new_worksheet = new_workbook.get_sheet(0) # 获取转化后工作簿中的第一个表格
for i in range(0, 1):
for j in range(0, len(value)):
new_worksheet.write(i+rows_old, j, value[j]) # 追加写入数据,注意是从i+rows_old行开始写入
new_workbook.save(path) # 保存工作簿
print("xls格式表格【追加】写入数据成功!")
city_list = get_city_list("https://www.lianjia.com/city/")
for i in city_list:
temp_list = []
print(i)
house_quantity = get_house_quantity(i[0])
print(house_quantity)
temp_list.append(i[0])
temp_list.append(i[1])
temp_list.append(house_quantity)
print(temp_list)
write_excel_xls_append("may.xls",temp_list)
time.sleep(2)
三、更新
广州4月销售套数TOP10

https://gz.newhouse.fang.com/2020-05-26/36206793.htm
广州5月销售套数TOP10 增城赢了!

https://gz.newhouse.fang.com/2020-06-01/36260451.htm
套数有差异,名称和这里的差不多。

四、二手
5-June-2020 广州链家真实在售二手房 73677 套
13-June-2020 广州链家真实在售二手房 74699 套
其中:
南沙:共找到 3185 套南沙二手房
增城:共找到 10056 套增城二手房
15-July-2020
广州链家真实在售二手房 76260 套
其中:
南沙:共找到 3332 套南沙二手房
增城:共找到 10385 套增城二手房
增城朱村科教板块:
山田站:荔富湖畔:88套在售二手房,97套出租房源,小区均价:15226元/m2
凤岗站:保利中航城:53套在售二手房,362套出租房源。18097元/m2,145万装修3房(83m2)。
新塘:
官湖地铁:锦绣天伦花园:317套在售二手房,52套出租房源,小区均价:18616元/m2 (143万2房带2千一个月租约)
官湖地铁:中森名苑, 36套在售二手房,7套出租房源,小区均价:18103元/m2
31-July-2020
广州链家真实在售二手房 76514 套
其中:
南沙:共找到 3339 套南沙二手房
增城:共找到 10487 套增城二手房
06-Oct-2020
共找到 78318 套广州二手房
其中:
南沙:共找到 3292 套南沙二手房
增城:共找到 11076 套增城二手房
Jan-24-2021
共找到 74551 套广州二手房
其中:
南沙:共找到 2998 套南沙二手房
增城:共找到 11131 套增城二手房
Feb-21-2021
共找到 73857 套广州二手房
其中:
南沙:共找到 3000 套南沙二手房
增城:共找到 11008 套增城二手房
Apr-02-2021
共找到 76033 套广州二手房
其中:
增城:共找到 11150 套增城二手房
南沙:共找到 3287 套南沙二手房
June-30-2021
共找到 79517 套广州二手房
其中:
增城:共找到 11924 套增城二手房
南沙:共找到 3711 套南沙二手房
Nov-06-2021
共找到 94853 套广州二手房
其中:
增城:共找到 13162 套增城二手房
南沙:共找到 4726 套南沙二手房
Dec-26-2021
共找到 98155 套广州二手房
其中:
增城:共找到 13246 套增城二手房
南沙:共找到 4979 套南沙二手房
Feb-27-2022
共找到 100986 套广州二手房
其中:
增城:共找到 13214 套增城二手房
南沙:共找到 5262 套南沙二手房
May-7-2022
共找到 104544 套广州二手房
其中:
增城:共找到13187套增城二手房
南沙:共找到 5513 套南沙二手房
May-21-2022
共找到 106467 套广州二手房
其中:
增城:共找到13275 套增城二手房
南沙:共找到 5647 套南沙二手房