Coder Social home page Coder Social logo

html_radar's Introduction

HtmlRadar

Finds Change in URL Content

Scrapes, Remembers, Outputs Change in URL Content."

Installation

# where: Gemfile
gem 'html_radar'

Locally (for test)

# where: terminal
gem install html_radar

Usage

Given the following:

  http://test.html = "
    <html><body>
      <p><a href='http://test.html'>Static</a></p>
    </body></html>
    "
  url = "test.html"
  css_selector = "a"
  item_tag = "ul"
  top_id = "_123_"

  memory = ""

Then html_radar takes a memory...

  memory = HtmlRadar.refresh(memory, url, css_selector, item_tag, top_id)

  memory == "
      <ul><a href='http://test.html'>Static</a></ul>
      <center><a href='#_123_'>###</a></center>
      <hr />
      <!-- split_tag -->
    "

Then html_radar shows change as current, because the past does not yet exist...

  change = HtmlRadar.show(memory).to_s
  change.scan("Static").present? #=> TRUE
  memory.scan("Static").present? #=> TRUE

  change == "
      <ul><a href='http://test.html'>Static</a></ul>
      <center><a href='#_123_'>###</a></center>
      <hr />
    "

Then html_radar shows no change, because the past is the same as he present...

  memory = HtmlRadar.refresh(memory, url, css_selector, item_tag, top_id)
  change = HtmlRadar.show(memory).to_s
  change.scan("Static").present? #=> FALSE
  memory.scan("Static").present? #=> TRUE

  change == ""

  memory == "
      <!-- split_tag -->
      <ul><a href='http://test.html'>Static</a></ul>
      <center><a href='#_123_'>###</a></center>
      <hr />
    "

Then html_radar shows "Change", because it is added to the new_memory...

  new_memory = "<a href="...">Change</a>"+memory
  memory = HtmlRadar.refresh(new_memory, url, css_selector, item_tag, top_id)
  memory_change = HtmlRadar.show(memory).to_s
  memory_change.scan("Change").present? #=> TRUE
  memory_change.scan("Static").present? #=> FALSE
  momory.scan("Static").present? #=> TRUE

  change == "
      <ul><a href="...">Change</a></ul>
      <center><a href='#_123_'>###</a></center>
      <hr />
    "

  memory == "
      <ul><a href="...">Change</a></ul>
      <center><a href='#_123_'>###</a></center>
      <hr />
      <!-- split_tag -->
      <ul><a href='http://test.html'>Static</a></ul>
      <center><a href='#_123_'>###</a></center>
      <hr />
    "

License

MIT-LICENSE.

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.