{"id":24862637,"url":"https://github.com/4rlm/mechanizer","last_synced_at":"2026-04-16T05:03:28.647Z","repository":{"id":56883173,"uuid":"139475260","full_name":"4rlm/mechanizer","owner":"4rlm","description":"Ruby Gem: Mechanize \u0026 NokoGiri Wrapper for Automated WebScraping and WebPage Parsing.","archived":false,"fork":false,"pushed_at":"2018-07-22T11:32:24.000Z","size":50,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-06-05T23:09:28.977Z","etag":null,"topics":["4rlm","adam-booth","adam-john-booth","css","data-mining","database","harvest","html","mechanize","mechanizer","mining","nokogiri","parsing","ruby-gem","scraper","scraping-websites"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/4rlm.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-07-02T17:43:21.000Z","updated_at":"2018-08-20T19:22:19.000Z","dependencies_parsed_at":"2022-08-20T13:10:50.208Z","dependency_job_id":null,"html_url":"https://github.com/4rlm/mechanizer","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/4rlm/mechanizer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/4rlm%2Fmechanizer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/4rlm%2Fmechanizer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/4rlm%2Fmechanizer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/4rlm%2Fmechanizer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/4rlm","download_url":"https://codeload.github.com/4rlm/mechanizer/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/4rlm%2Fmechanizer/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259645808,"owners_count":22889684,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["4rlm","adam-booth","adam-john-booth","css","data-mining","database","harvest","html","mechanize","mechanizer","mining","nokogiri","parsing","ruby-gem","scraper","scraping-websites"],"created_at":"2025-01-31T22:59:19.951Z","updated_at":"2025-10-31T07:33:33.303Z","avatar_url":"https://github.com/4rlm.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Mechanizer\n\n[![Build Status](https://travis-ci.org/4rlm/mechanizer.svg?branch=master)](https://travis-ci.org/4rlm/mechanizer)\n[![Gem Version](https://badge.fury.io/rb/mechanizer.svg)](https://badge.fury.io/rb/mechanizer)\n[![MIT License](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n### Mechanize \u0026 NokoGiri Wrapper for Automated WebScraping and WebPage Parsing.\n\nLight, easy to use wrapper for Mechanize and NokoGiri.  No configuration or error handling to worry about.  Simply enter the target URL and Mechanizer scrapes the page for you to easily parse.\n\n### Recommended Gems\nNote: URL MUST be in proper format and be valid, example:\n\nCorrect: https://www.example.com\n\nIncorrect: www.example.com, example.com, https://example.com\n\n1. If you need to pre-format your URLs, try using `CrmFormatter gem`\n2. If you need to verify your URLs, try using `UrlVerifier gem`, which includes the `CrmFormatter gem` inside of it.\n\nThen, feed the results from those gems into this gem.  The documentation below assumes the URLs are correctly formatted and have been verified before passing them through the `Mechanizer gem`.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'mechanizer'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install mechanizer\n\n## Usage\n\n### 1. Instantiate \u0026 Pass URL\n\n```\nnoko = Mechanizer::Noko.new\nnoko_hash = noko.scrape({url: 'https://www.wikipedia.org'})\n```\n\n### 2. To Customize Timeout:\nDefault timeout is set to 60.  You can adjust that time or omit it if 60 is fine.\n\n```\nnoko = Mechanizer::Noko.new\nargs = {url: 'https://www.wikipedia.org', timeout: 30}\nnoko_hash = noko.scrape(args)\n```\n\n### 3. Noko Result in Hash Format\n\n```\nerr_msg = noko_hash[:err_msg]\npage = noko_hash[:page]\ntexts_and_paths = noko_hash[:texts_and_paths]\n```\n\n### 4. Example Texts \u0026 paths:\n\n```\ntexts_and_paths = [\n  {:text=\u003e\"english 5 675 000+ articles\", :path=\u003e\"//en.wikipedia.org/\"},\n  {:text=\u003e\"日本語 1 111 000+ 記事\", :path=\u003e\"//ja.wikipedia.org/\"},\n  {:text=\u003e\"español 1 427 000+ artículos\", :path=\u003e\"//es.wikipedia.org/\"},\n  {:text=\u003e\"deutsch 2 195 000+ artikel\", :path=\u003e\"//de.wikipedia.org/\"},\n  {:text=\u003e\"русский 1 481 000+ статей\", :path=\u003e\"//ru.wikipedia.org/\"},\n  {:text=\u003e\"français 1 997 000+ articles\", :path=\u003e\"//fr.wikipedia.org/\"},\n  {:text=\u003e\"italiano 1 446 000+ voci\", :path=\u003e\"//it.wikipedia.org/\"}\n]\n```\n\n### 5. Example Parsing Page:\nThere are several ways to parse and manipulate `noko_hash[:page]`.  Essentially, you can parse the page using its css classes and html tags.  You can use either or both together.  Some pages are very straight forward, but others can require a lot of skill.  Here is a good reference guide: [Nokogiri Tutorials](http://www.nokogiri.org/tutorials).  All Nokogiri methods are available through this wrapper.  This wrapper simply helps you avoid setting up, manages and reduces errors, and helps to automate your scraping process.\n\nFor the Wikipedia URL in the example above, at the time of this README there is a group of icons on its homepage.  If you right-click on any of them you can inspect.  Look for any classes that interest you.  In this example, it's `.other-project`.  Simply paste it like below to get started.  Remember, there are several ways to do this, so read the docs and explore what's available.\n\n```\nother_projects = page.css('.other-project')\u0026.text\nother_projects = other_projects.split(\"\\n\").reject(\u0026:blank?)\n```\n\n### 6. Results from Parsing Page (from example 5):\n\n```\nother_projects = [\n  \"Commons\",\n  \"Freely usable photos \u0026 more\",\n  \"Wikivoyage\",\n  \"Free travel guide\",\n  \"Wiktionary\",\n  \"Free dictionary\",\n  \"Wikibooks\",\n  \"Free textbooks\",\n  \"Wikinews\",\n  \"Free news source\",\n  \"Wikidata\",\n  \"Free knowledge base\",\n  \"Wikiversity\",\n  \"Free course materials\",\n  \"Wikiquote\",\n  \"Free quote compendium\",\n  \"MediaWiki\",\n  \"Free \u0026 open wiki application\",\n  \"Wikisource\",\n  \"Free library\",\n  \"Wikispecies\",\n  \"Free species directory\",\n  \"Meta-Wiki\",\n  \"Community coordination \u0026 documentation\"\n]\n```\n\n### 7. Automating Your Scraping:\nYou may wish to automate your scraping for various reasons including:\n\n* Verifing Inventory Items and Pricing (car dealers, retail, menus, etc.),\n* Categorizing News Headlines and Events,\n* Creating Data Sets (financials, economic, weather, crime, health)\n\nRegardless of how you intend to scrape, you will need to find common patterns on the pages.  If visiting different websites, each might use their own css, so you might like to create templates for certain ones.  So, in your database next to the URL, you might specify which template to use for which URL.  Each template has it's own CSS for that URL.\n\nYou could create a wrapper around these results, like so (just an example):\n\n```\ncity_urls = ['https://en.wikipedia.org/wiki/Austin,_Texas', https://en.wikipedia.org/wiki/Chicago, https://en.wikipedia.org/wiki/Denver]\nnoko = Mechanizer::Noko.new\n\ncity_data = city_urls.map do |city_url|\n  noko_hash = noko.scrape({ url: city_url })\n  city_parser(noko_hash)\nend\n\ndef city_parser(noko_hash)\n  # Your logic here.\nend\n```\n\n\n## Author\n\nAdam J Booth  - [4rlm](https://github.com/4rlm)\n\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/mechanizer. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n\n## Code of Conduct\n\nEveryone interacting in the Mechanizer project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/mechanizer/blob/master/CODE_OF_CONDUCT.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F4rlm%2Fmechanizer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F4rlm%2Fmechanizer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F4rlm%2Fmechanizer/lists"}