Coder Social home page Coder Social logo

mobike-crawler's Introduction

摩拜单车爬虫

声明:此爬虫仅用于学习、研究用途,请不要用于非法用途。任何由此引发的法律纠纷自行负责。

这个仓库的版本已经很古老了,基于此爬虫的更高级的版本已经在我的《爬虫实战:从数据到产品》一书中详细讲述,请参考:https://item.jd.com/12575102.html

书籍源代码:https://github.com/derekhe/crawler-book

书中全是干货,在介绍共享单车的同时也对共享汽车的爬取思路进行了详细描述。如能购买一本进行阅读,算是对我的莫大的支持。

请注意,此书写于2018年中,当时摩拜单车还能进行爬取,2018年12月他们更新了API,每次返回的数量变少,不能实现大规模的爬取,只能实现小区域的采集。可以借鉴书中思路,自行编写程序。

我的公众的微信bcdata,有问题可以加微信,但由于时间有限,恕不能一一回答,望见谅。

以下是一些老黄历,已经不能用了

该代码爬取摩拜单车的微信小程序接口,以便用于共享单车的分析。 相关文章:

目录结构:

  • \analysis - jupyter做数据分析
  • \influx-importer - 导入到influxdb,但之前没怎么弄好
  • \modules - 代理模块
  • \web - 实时图形化显示模块,当时只是为了学一下react而已,效果请见这里(注:服务端已经关闭,无法正常查看)
  • crawler.py - 爬虫核心代码
  • importToDb.py - 导入到postgres数据库中进行分析
  • sql.sql - 创建表的sql
  • start.sh - 持续运行的脚本

使用前请更新代理池,我这里仅仅提供的是一个样例,里面的代理很有可能已经失效:

r = requests.get("https://jsonblob.com/api/jsonBlob/31bf2dc8-00e6-11e7-a0ba-e39b7fdbe78b", timeout=10)

运行需求

python3 + numpy 组件
  • ujson 被移除,改用了 python自带的 json 以及将ujson.decode换成了json.loads(有些人的电脑是装不上ujson的……) 使用: 代码中的参数经过了@zxj5470的修改…… 原始数据意思左上右下表示理解不能……坐标数值上(纬度上)left比rifht大,(经度)top比bottom数值小。 这样的设定有点反人类啊。
  • 有强迫症的我给改了。下面对于的np.arange也进行了修改并经过测试。
# 作者版本原始数据格式:
    left = 30.7828453209    #左上角点的纬度
    top = 103.9213455517    #左上角点的经度
    
    right = 30.4781772402    #右下角点的纬度
    bottom = 104.2178123382    #右下角点的纬度

    
# 经过zxj5470修改后的:
    left_lng = 103.9213455517    #左上角点的经度
    top_lat = 30.7828453209    #左上角点的纬度
    
    right_lng = 104.2178123382    #右下角点的经度
    bottom_lat =  30.4781772402   #右下角点的纬度
   

mobike-crawler's People

Contributors

derekhe avatar zxj5470 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.