{"id":67,"date":"2016-07-19T19:14:12","date_gmt":"2016-07-19T19:14:12","guid":{"rendered":"http:\/\/wizardofbots.com\/network\/?p=67"},"modified":"2016-07-19T21:32:07","modified_gmt":"2016-07-19T21:32:07","slug":"osmosis-one-of-the-best-web-scrapers-in-nodejs","status":"publish","type":"post","link":"https:\/\/wizardofbots.com\/network\/osmosis-one-of-the-best-web-scrapers-in-nodejs\/","title":{"rendered":"Osmosis one of the best web scrapers in NodeJS"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" class=\"alignright\" src=\"https:\/\/media.giphy.com\/media\/Urf7wFa0FPlba\/giphy.gif\" width=\"240\" height=\"121\" \/><\/p>\n<p>Hell yeah, this also deserves the place along nightmareJS, even though this doesnt use Electron for simulating browser, but a headless parser native libxml C bindings that will do a great job.<\/p>\n<p>To start, you have to make sure you have previously installed <strong>nodejs<\/strong> libraries along with <strong>npm <\/strong>and if you get an error for the <strong>libxmljs<\/strong> library, make sure that you install this:<\/p>\n<pre class=\"lang-js prettyprint prettyprinted\"><code>npm install node-gyp \r\nnpm install libxmljs \r\nnpm install osmosis<\/code><\/pre>\n<p>And then it should be working properly if you create a file.js and run the example script.<\/p>\n<p>Here you have a bunch of examples to copy and paste to test it. In order to explain it further please ask your questions or requirements for video tutorials. I might open a premium spot for it, so you better fucking invite me a cup of oil so I can continue my compromise with you.<\/p>\n<p>Craiglist example:<\/p>\n<pre class=\"lang:js decode:true \">var osmosis = require('osmosis');\r\n\r\nosmosis\r\n.get('www.craigslist.org\/about\/sites')\r\n.find('h1 + div a')\r\n.set('location')\r\n.follow('@href')\r\n.find('header + div + div li &gt; a')\r\n.set('category')\r\n.follow('@href')\r\n.paginate('.totallink + a.button.next:first')\r\n.find('p &gt; a')\r\n.follow('@href')\r\n.set({\r\n    'title':        'section &gt; h2',\r\n    'description':  '#postingbody',\r\n    'subcategory':  'div.breadbox &gt; span[4]',\r\n    'date':         'time@datetime',\r\n    'latitude':     '#map@data-latitude',\r\n    'longitude':    '#map@data-longitude',\r\n    'images':       ['img@src']\r\n})\r\n.data(function(listing) {\r\n    \/\/ do something with listing data\r\n})\r\n.log(console.log)\r\n.error(console.log)\r\n.debug(console.log)<\/pre>\n<p>This is the official repo for Osmosis: <a href=\"https:\/\/github.com\/rchipka\/node-osmosis\" target=\"_blank\">https:\/\/github.com\/rchipka\/node-osmosis<\/a><\/p>\n<p>It works like this:<\/p>\n<p><iframe loading=\"lazy\" width=\"640\" height=\"360\" src=\"https:\/\/www.youtube.com\/embed\/8KmZmgEMfD4\" frameborder=\"0\" allowfullscreen><\/iframe><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hell yeah, this also deserves the place along nightmareJS, even though this doesnt use Electron for simulating browser, but a headless parser native libxml C bindings that will do a great job. To start, you have to make sure you have previously installed nodejs libraries along with npm and if you get an error for [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[33],"tags":[39,40,38],"class_list":["post-67","post","type-post","status-publish","format-standard","hentry","category-javascript","tag-nodejs","tag-osmosis","tag-scrapers"],"_links":{"self":[{"href":"https:\/\/wizardofbots.com\/network\/wp-json\/wp\/v2\/posts\/67","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wizardofbots.com\/network\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wizardofbots.com\/network\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wizardofbots.com\/network\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wizardofbots.com\/network\/wp-json\/wp\/v2\/comments?post=67"}],"version-history":[{"count":7,"href":"https:\/\/wizardofbots.com\/network\/wp-json\/wp\/v2\/posts\/67\/revisions"}],"predecessor-version":[{"id":74,"href":"https:\/\/wizardofbots.com\/network\/wp-json\/wp\/v2\/posts\/67\/revisions\/74"}],"wp:attachment":[{"href":"https:\/\/wizardofbots.com\/network\/wp-json\/wp\/v2\/media?parent=67"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wizardofbots.com\/network\/wp-json\/wp\/v2\/categories?post=67"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wizardofbots.com\/network\/wp-json\/wp\/v2\/tags?post=67"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}