xjkj123 / lianjia Goto Github PK
View Code? Open in Web Editor NEW链家二手房爬虫,抓取房价,经纬度位置,及60多个字段信息,接口调用无限制
License: GNU General Public License v3.0
链家二手房爬虫,抓取房价,经纬度位置,及60多个字段信息,接口调用无限制
License: GNU General Public License v3.0
每个区域的经纬度数组仅在刚调用HoleCityDown时初始化一次,之后对每个区域的抓取都会叠加上一个区域的经纬度数组,数组越来越大,导致重复抓取
改进:
lat = []
lng = []
应当移动到
for x in area_list:
以内
100%|███████████████████████████████████████| 2460/2460 [08:58<00:00, 4.88it/s]
100%|███████████████████████████████████████| 2580/2580 [09:10<00:00, 4.39it/s]
57%|██████████████████████▍ | 2139/3721 [07:40<05:45, 4.58it/s]100%|███████████████████████████████████████| 3721/3721 [13:28<00:00, 4.82it/s]
7%|██▍ | 1504/22010 [05:22<1:12:00, 4.75it/s]100%|███████████████████████████████████| 22010/22010 [1:22:34<00:00, 4.49it/s]
0%| | 0/8116 [00:00<?, ?it/s]Traceback (most recent call last):
File "test.py", line 7, in
lj.GetCompleteHousingInfo(city)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/Lianjia/lianjia.py", line 505, in GetCompleteHousingInfo
ret = Lianjia(city).GetHousingInfo(x[0], x[1])
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/Lianjia/lianjia.py", line 386, in GetHousingInfo
for x in house_json['data']['ershoufang_info']['list']:
TypeError: 'NoneType' object is not subscriptable
直接执行代码lianjia.py,前面两步正常,执行到第三步GetCompleteHousingInfo()时会直接报错,错误代码如下:
Traceback (most recent call last):
File "lianjia.py", line 351, in
GetCompleteHousingInfo(city)#获取详细在售房屋
File "lianjia.py", line 332, in GetCompleteHousingInfo
ret = Lianjia(city).GetHousingInfo(x[0], x[1])
File "lianjia.py", line 214, in GetHousingInfo
for x in house_json['data']['ershoufang_info']['list']:
TypeError: 'NoneType' object is not subscriptable
此时如果切换使用pip包的方式调用执行第三步
import Lianjia.lianjia as lj
city='上海'
lj.GetCompleteHousingInfo(city)
则可以接着执行,不会出现上述错误
将出错代码前一行的ret.text内容print出来为:
jQuery111106822012072868358_1534402288206({"request_id":"1914311585","uniq_id":"D41F-612E-203B-50C1-CA3355E268DD","errno":10001,"error":"invalid request","data":null})
似乎是Get请求失败了?
linux和windows测试现象都是这样,换了网络也是不行
您好,很感谢您能分享您的代码。我在运行时发现detailinfo中的数据和lianjia_area中count相加的数据量不符。例如北京的detailinfo中我得到了6180条数据,而lianjia_area中count相加有80347条数据,运行过程中并无中断,想请问一下这样正常吗?
然后就必须重新再来,因为我不懂sql,所以想问问如何手动断点续传,跳过之前爬过的部分
希望可以支持武汉
首先,链家现在会封ip的,然后按照你这里的逻辑最后抓取的数据会有很大问题,以武汉为例
目前支持城市中没有郑州,不知道是否存在可能支持?
非常感谢
跑了您的代码我觉得非常nice,很感谢您.
是这样,我想爬取全国的信息,但city_dict里面目前只有5个城市参数,如果您还没有更新,可以说一下那四个参数最大、小经纬度是怎么获取的吗,目前我只找到了city_id.如果您代码更新了可以分享一下吗.再次感谢!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.