Code Monkey home page Code Monkey logo

common_spider's Introduction

spider脚本

一个爬取页面URL的脚本

在原来项目的基础上进行了魔改,我的需求是传入一个URL之后爬取页面中与它相关的URL

为什么不直接使用crawlergo这类项目?虽然crawlergo的爬取已经足够使用了,但需要-c指定浏览器。如果我们想要将其合并到自己的项目里面,就很难做到跨平台。

github上面另外的一些项目感觉都不太符合自己的要求,要么就是需要的库文件太多了,所以进行了魔改

魔改主要所作的工作如下:

  • 首先将适用于python2的项目升级为python3
  • 修改了例如url_protocol函数中的错误,else逻辑中返回错误协议
    def url_protocol(url):
        domain = re.findall(r'.*(?=://)', url)
        if domain:
            return domain[0]
        else:
            return url
  • 加强了静态文件后缀的过滤正则
  • 去除了一些畸形URL
  • 将命令行输入修改为函数调用
  • ...

Usage

使用比较简单:

安装requests依赖

pip install requests

运行爬虫,调用spider函数即可,传入url和爬取深度,默认为1,返回result为结果列表,更方便将其内嵌到自己的项目里

screenshot

common_spider's People

Contributors

cl0udg0d avatar tidesec avatar

Stargazers

 avatar

Forkers

you2er

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.