GithubHelp home page GithubHelp logo

crawler's Introduction

crawler

A web crawler project

实现的功能

  1. 最基本的访问网站,发送 http request 请求。获取 http response 的能力
  2. 对有些非 UTF-8 编码的 response 进行统一的转码处理
  3. 使用正则表达式 regexp 对返回的 response 中的有效数据进行数据提取过滤
  4. 模拟浏览器访问网站来绕过网站反爬虫机制,包括设置 http request 的头部 User-Agent 字段, proxy, cookies, ip代理池
  5. http.Client对象默认会从环境变量读取 HTTP_PROXY, HTTPS_PROXY, NO_PROXY, 其作用之一为反爬,另一个作用为访问外网
  6. 可以通过设置clinet的transport成员来修改代理规则,并且使用分别使用轮询和一致性哈希算法作为负载均衡算法
  7. 对不同类型网站需要设置不同的遍历算法,例如,豆瓣这种翻页式网站需要分析URL手动构建URL队列,对于树形超链接则需要使用深度优先或者广度优先获取所有URL,同时防止链接环路需要先利用广度优先拓扑排序算法将URL遍历一遍后放到URL队列中,然后再按顺序进行访问,这里一般在实际项目中采用广度优先,因为深度优先采用递归实现会造成递归栈过深的问题

crawler's People

Contributors

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