All Projects → bachors → Ygrab.js

bachors / Ygrab.js

Licence: MIT license
Dynamic web scrapping by CSS selectors

Programming Languages

javascript
184084 projects - #8 most used programming language
HTML
75241 projects

Ygrab.js

Dynamic web scrapping that allows you to turn any site into a JSON accessible api using CSS selectors. This api using google script.

Usage:

<script src="https://github.com//code.jquery.com/jquery-2.2.4.min.js"></script>
<script src="js/ygrab.js"></script>
<script>        
$(function() {
var data = [
    {
        url: 'http://bachors.com/blog', // url string rquired
        selector: 'div.post', // selector string rquired
        loop: true, // each boolean rquired
        result: [
            {
                name: 'title', // key string rquired
                find: 'h3 a', // selector child string rquired
                grab: {
                    by: 'text', // attribut string rquired
                    value: '' // attribut value string optional
                }
            },
            {
                name: 'link',
                find: 'h3 a',
                grab: {
                    by: 'attr',
                    value: 'href'
                }
            },
            // ---- new selector ---- //
        ]
    },
    // ---- new website url ---- //
];

ygrab(data, function(result) {
	console.log(JSON.stringify(result, null, 2));
});

}); </script>

Result:

[
  {
    "title": "Membuat Aplikasi Android Pencarian Kode POS ",
    "link": "http://bachors.com/blog/membuat-aplikasi-android-pencarian-kode-pos"
  },
  {
    "title": "Cara mengkonversi video ke gif menggunakan javascript",
    "link": "http://bachors.com/blog/how-to-convert-video-to-gif-using-javascript"
  },
  {
    "title": "Cara Backup File & Database di Codeigniter",
    "link": "http://bachors.com/blog/cara-backup-file-database-di-codeigniter"
  },
  {
    "title": "Membuat aplikasi chatting secara real time menggunakan firebase & jQuery",
    "link": "http://bachors.com/blog/membuat-aplikasi-chatting-secara-real-time-menggunakan-firebase-jquery"
  },
  {
    "title": "Cara membuat website menjadi ringan & cepat",
    "link": "http://bachors.com/blog/cara-membuat-website-menjadi-ringan-cepat"
  },
  {
    "title": "Contoh setting file .htaccess",
    "link": "http://bachors.com/blog/contoh-setting-file-htaccess"
  }
]
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].