Coder Social home page Coder Social logo

spider-code's Introduction

pyspider code

最近工作需求,花了一个周末看了一下python。 学习了一下 廖雪峰 的教程,了解了一下python的语法。

自己基于python的一些简单的类库,写了几个小的数据抓取脚本。 发现抓取大量数据的时候,涉及到多进程、时间有效性、自动执行等问题,都需要自己解决。 于是翻了翻知乎,发现有人在介绍 pyspider。 花2个小时,读了一下 pyspider 的说明文档,看了一下 demo 中的一些代码。

发现确实很实用,自己想要的功能,基本都已经实现了。 于是马上安装、配置,开始用了起来。

用的mac,装pip,virtualenv,其他的类库都是在开发过程中,看需求添加的。

写脚本抓取了

  1. 练手:zhihu中自己关注的专栏中的文章内容

  2. 练手:jandan的ooxx图 (jandan的通过限制cookie的方式来防止抓取,果然是被抓经验丰富,只要判断返回状态值,状态值不是200的时候,手工刷新一下页面,点击一下按钮,这个地方可以回头想想有没有办法机器来做)

  3. 国内top5的海淘App的商品信息 (用Replica抓App中的请求地址) (higo返回商品信息的接口使用的jsonp,需要处理,这个地方花了我一些时间)

  4. 国内最大的四家电视购物网站的商品信息

简要总结:

  1. 安装类库 MySQL-python 花了一些精力,主要是由于自己用的是套装安装的
  2. 抓数据,花在读取页面内容的时间上比较多,如果有直接api接口是最省事的,有手机端网站页面其次,直接解析页面也不费事,有的网站写的比较拧巴,页面加载一部分,js加载一部分html,js再加载一部分json,真替维护的开发人员觉得累。

spider-code's People

Contributors

wzq19822004 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.