Permalink
Browse files

squashed all my implementations of this scraper into this commit

0 parents commit 8937d80d42f409a503d88d9eeec11f0a820ada83 @martinsbalodis committed Nov 23, 2013
Showing with 38,410 additions and 0 deletions.
  1. +3 −0 .gitignore
  2. +3 −0 .gitmodules
  3. +165 −0 LICENSE
  4. +57 −0 README.md
  5. BIN docs/images/chrome-store-logo.png
  6. BIN docs/images/chrome-store-logo.xcf
  7. BIN docs/images/sitemap-tree.png
  8. +2 −0 docs/images/store-logo-sources.txt
  9. +552 −0 extension/assets/ICanHaz.js
  10. +26 −0 extension/assets/LICENSE-d3-js
  11. +26 −0 extension/assets/LICENSE-icanhaz-js
  12. +21 −0 extension/assets/LICENSE-jquery-js
  13. +227 −0 extension/assets/LICENSE-pouchdb-js
  14. +5 −0 extension/assets/LICENSE-sugar-js
  15. +384 −0 extension/assets/bootstrap-3.0.0/css/bootstrap-theme.css
  16. +1 −0 extension/assets/bootstrap-3.0.0/css/bootstrap-theme.min.css
  17. +6,805 −0 extension/assets/bootstrap-3.0.0/css/bootstrap.css
  18. +9 −0 extension/assets/bootstrap-3.0.0/css/bootstrap.min.css
  19. BIN extension/assets/bootstrap-3.0.0/fonts/glyphicons-halflings-regular.eot
  20. +228 −0 extension/assets/bootstrap-3.0.0/fonts/glyphicons-halflings-regular.svg
  21. BIN extension/assets/bootstrap-3.0.0/fonts/glyphicons-halflings-regular.ttf
  22. BIN extension/assets/bootstrap-3.0.0/fonts/glyphicons-halflings-regular.woff
  23. +1,999 −0 extension/assets/bootstrap-3.0.0/js/bootstrap.js
  24. +6 −0 extension/assets/bootstrap-3.0.0/js/bootstrap.min.js
  25. +1 −0 extension/assets/css-selector
  26. +9,234 −0 extension/assets/d3.v3.js
  27. +5 −0 extension/assets/d3.v3.min.js
  28. +5 −0 extension/assets/images/LICENSE
  29. BIN extension/assets/images/icon128.png
  30. BIN extension/assets/images/icon16.png
  31. BIN extension/assets/images/icon19.png
  32. BIN extension/assets/images/icon38.png
  33. BIN extension/assets/images/icon48.png
  34. +8,829 −0 extension/assets/jquery-2.0.3.js
  35. +4 −0 extension/assets/pouchdb-nightly.min.js
  36. +132 −0 extension/assets/sugar-1.4.1.js
  37. +120 −0 extension/background_page/background_script.js
  38. +46 −0 extension/content_script/content_script.css
  39. +55 −0 extension/content_script/content_script.js
  40. +5 −0 extension/devtools/devtools_init_page.html
  41. +1 −0 extension/devtools/devtools_init_page.js
  42. +78 −0 extension/devtools/devtools_scraper_panel.css
  43. +28 −0 extension/devtools/devtools_scraper_panel.html
  44. +80 −0 extension/devtools/views/SelectorEdit.html
  45. +21 −0 extension/devtools/views/SelectorList.html
  46. +11 −0 extension/devtools/views/SelectorListItem.html
  47. +13 −0 extension/devtools/views/SitemapBrowseData.html
  48. +21 −0 extension/devtools/views/SitemapCreate.html
  49. +23 −0 extension/devtools/views/SitemapEditMetadata.html
  50. +7 −0 extension/devtools/views/SitemapExport.html
  51. +4 −0 extension/devtools/views/SitemapExportDataCSV.html
  52. +14 −0 extension/devtools/views/SitemapImport.html
  53. +13 −0 extension/devtools/views/SitemapList.html
  54. +9 −0 extension/devtools/views/SitemapListItem.html
  55. +1 −0 extension/devtools/views/SitemapSelectorGraph.html
  56. +35 −0 extension/devtools/views/Viewport.html
  57. +73 −0 extension/manifest.json
  58. +57 −0 extension/options_page/options.html
  59. +78 −0 extension/options_page/options_page.js
  60. +11 −0 extension/scripts/App.js
  61. +87 −0 extension/scripts/ChromePopupBrowser.js
  62. +49 −0 extension/scripts/Config.js
  63. +217 −0 extension/scripts/ContentSelector.js
  64. +610 −0 extension/scripts/Controller.js
  65. +190 −0 extension/scripts/DataExtractor.js
  66. +66 −0 extension/scripts/Job.js
  67. +57 −0 extension/scripts/Queue.js
  68. +108 −0 extension/scripts/Scraper.js
  69. +89 −0 extension/scripts/Selector.js
  70. +34 −0 extension/scripts/Selector/SelectorElement.js
  71. +54 −0 extension/scripts/Selector/SelectorGroup.js
  72. +50 −0 extension/scripts/Selector/SelectorLink.js
  73. +58 −0 extension/scripts/Selector/SelectorText.js
  74. +149 −0 extension/scripts/SelectorGraph.js
  75. +219 −0 extension/scripts/SelectorGraphv2.js
  76. +154 −0 extension/scripts/SelectorList.js
  77. +142 −0 extension/scripts/Sitemap.js
  78. +125 −0 extension/scripts/Store.js
  79. +62 −0 extension/scripts/StoreDevtools.js
  80. +20 −0 jasmine-standalone/lib/jasmine-1.3.1/MIT.LICENSE
  81. +681 −0 jasmine-standalone/lib/jasmine-1.3.1/jasmine-html.js
  82. +82 −0 jasmine-standalone/lib/jasmine-1.3.1/jasmine.css
  83. +2,600 −0 jasmine-standalone/lib/jasmine-1.3.1/jasmine.js
  84. +231 −0 playgrounds/extension/index.html
  85. +16 −0 playgrounds/extension/webpage.css
  86. +22 −0 playgrounds/sitemap-tree/index.html
  87. +24 −0 playgrounds/sitemap-tree/sitemap.json
  88. +16 −0 playgrounds/sitemap-tree/style.css
  89. +114 −0 tests/ChromeAPI.js
  90. +17 −0 tests/FakeStore.js
  91. +60 −0 tests/Matchers.js
  92. +241 −0 tests/SpecRunner.html
  93. +72 −0 tests/spec/ChromePopupBrowserSpec.js
  94. +85 −0 tests/spec/ContentSelectorSpec.js
  95. +940 −0 tests/spec/DataExtractSpec.js
  96. +26 −0 tests/spec/JobSpec.js
  97. +36 −0 tests/spec/QueueSpec.js
  98. +155 −0 tests/spec/ScraperSpec.js
  99. +44 −0 tests/spec/Selector/SelectorElementSpec.js
  100. +92 −0 tests/spec/Selector/SelectorGroupSpec.js
  101. +76 −0 tests/spec/Selector/SelectorLinkSpec.js
  102. +130 −0 tests/spec/Selector/SelectorTextSpec.js
  103. +253 −0 tests/spec/SelectorListSpec.js
  104. +5 −0 tests/spec/SelectorSpec.js
  105. +319 −0 tests/spec/SitemapSpec.js
@@ -0,0 +1,3 @@
+.idea
+projectFilesBackup
+
@@ -0,0 +1,3 @@
+[submodule "extension/assets/css-selector"]
+ path = extension/assets/css-selector
+ url = https://github.com/martinsbalodis/css-selector.git
@@ -0,0 +1,165 @@
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+
+ This version of the GNU Lesser General Public License incorporates
+the terms and conditions of version 3 of the GNU General Public
+License, supplemented by the additional permissions listed below.
+
+ 0. Additional Definitions.
+
+ As used herein, "this License" refers to version 3 of the GNU Lesser
+General Public License, and the "GNU GPL" refers to version 3 of the GNU
+General Public License.
+
+ "The Library" refers to a covered work governed by this License,
+other than an Application or a Combined Work as defined below.
+
+ An "Application" is any work that makes use of an interface provided
+by the Library, but which is not otherwise based on the Library.
+Defining a subclass of a class defined by the Library is deemed a mode
+of using an interface provided by the Library.
+
+ A "Combined Work" is a work produced by combining or linking an
+Application with the Library. The particular version of the Library
+with which the Combined Work was made is also called the "Linked
+Version".
+
+ The "Minimal Corresponding Source" for a Combined Work means the
+Corresponding Source for the Combined Work, excluding any source code
+for portions of the Combined Work that, considered in isolation, are
+based on the Application, and not on the Linked Version.
+
+ The "Corresponding Application Code" for a Combined Work means the
+object code and/or source code for the Application, including any data
+and utility programs needed for reproducing the Combined Work from the
+Application, but excluding the System Libraries of the Combined Work.
+
+ 1. Exception to Section 3 of the GNU GPL.
+
+ You may convey a covered work under sections 3 and 4 of this License
+without being bound by section 3 of the GNU GPL.
+
+ 2. Conveying Modified Versions.
+
+ If you modify a copy of the Library, and, in your modifications, a
+facility refers to a function or data to be supplied by an Application
+that uses the facility (other than as an argument passed when the
+facility is invoked), then you may convey a copy of the modified
+version:
+
+ a) under this License, provided that you make a good faith effort to
+ ensure that, in the event an Application does not supply the
+ function or data, the facility still operates, and performs
+ whatever part of its purpose remains meaningful, or
+
+ b) under the GNU GPL, with none of the additional permissions of
+ this License applicable to that copy.
+
+ 3. Object Code Incorporating Material from Library Header Files.
+
+ The object code form of an Application may incorporate material from
+a header file that is part of the Library. You may convey such object
+code under terms of your choice, provided that, if the incorporated
+material is not limited to numerical parameters, data structure
+layouts and accessors, or small macros, inline functions and templates
+(ten or fewer lines in length), you do both of the following:
+
+ a) Give prominent notice with each copy of the object code that the
+ Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the object code with a copy of the GNU GPL and this license
+ document.
+
+ 4. Combined Works.
+
+ You may convey a Combined Work under terms of your choice that,
+taken together, effectively do not restrict modification of the
+portions of the Library contained in the Combined Work and reverse
+engineering for debugging such modifications, if you also do each of
+the following:
+
+ a) Give prominent notice with each copy of the Combined Work that
+ the Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
+ document.
+
+ c) For a Combined Work that displays copyright notices during
+ execution, include the copyright notice for the Library among
+ these notices, as well as a reference directing the user to the
+ copies of the GNU GPL and this license document.
+
+ d) Do one of the following:
+
+ 0) Convey the Minimal Corresponding Source under the terms of this
+ License, and the Corresponding Application Code in a form
+ suitable for, and under terms that permit, the user to
+ recombine or relink the Application with a modified version of
+ the Linked Version to produce a modified Combined Work, in the
+ manner specified by section 6 of the GNU GPL for conveying
+ Corresponding Source.
+
+ 1) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (a) uses at run time
+ a copy of the Library already present on the user's computer
+ system, and (b) will operate properly with a modified version
+ of the Library that is interface-compatible with the Linked
+ Version.
+
+ e) Provide Installation Information, but only if you would otherwise
+ be required to provide such information under section 6 of the
+ GNU GPL, and only to the extent that such information is
+ necessary to install and execute a modified version of the
+ Combined Work produced by recombining or relinking the
+ Application with a modified version of the Linked Version. (If
+ you use option 4d0, the Installation Information must accompany
+ the Minimal Corresponding Source and Corresponding Application
+ Code. If you use option 4d1, you must provide the Installation
+ Information in the manner specified by section 6 of the GNU GPL
+ for conveying Corresponding Source.)
+
+ 5. Combined Libraries.
+
+ You may place library facilities that are a work based on the
+Library side by side in a single library together with other library
+facilities that are not Applications and are not covered by this
+License, and convey such a combined library under terms of your
+choice, if you do both of the following:
+
+ a) Accompany the combined library with a copy of the same work based
+ on the Library, uncombined with any other library facilities,
+ conveyed under the terms of this License.
+
+ b) Give prominent notice with the combined library that part of it
+ is a work based on the Library, and explaining where to find the
+ accompanying uncombined form of the same work.
+
+ 6. Revised Versions of the GNU Lesser General Public License.
+
+ The Free Software Foundation may publish revised and/or new versions
+of the GNU Lesser General Public License from time to time. Such new
+versions will be similar in spirit to the present version, but may
+differ in detail to address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Library as you received it specifies that a certain numbered version
+of the GNU Lesser General Public License "or any later version"
+applies to it, you have the option of following the terms and
+conditions either of that published version or of any later version
+published by the Free Software Foundation. If the Library as you
+received it does not specify a version number of the GNU Lesser
+General Public License, you may choose any version of the GNU Lesser
+General Public License ever published by the Free Software Foundation.
+
+ If the Library as you received it specifies that a proxy can decide
+whether future versions of the GNU Lesser General Public License shall
+apply, that proxy's public statement of acceptance of any version is
+permanent authorization for you to choose that version for the
+Library.
@@ -0,0 +1,57 @@
+# Web Scraper
+Web Scraper is a chrome browser extension built for data extraction from web pages. Using this extension you can create a plan (sitemap) how a web site should be traversed and what should be extracted. Using these sitemaps the Web Scraper will navigate the site accordingly and extract all data. Scraped data later can be exported as CSV.
+
+### Features
+
+ 1. Scrape multiple pages
+ 2. Sitemaps and scraped data are stored in browsers local storage or in CouchDB
+ 3. Multiple data selection types
+ 4. Browse scraped data
+ 5. Export scraped data as CSV
+ 6. Import, Export sitemaps
+ 7. Depends only on Chrome browser
+
+## How to use it
+Imagine an on-line store that is selling items you are interested in. These items are grouped by category and also there are only 10 items visible per page. The rest of the items are accessible via pagination.
+
+To scrape this kind of a page you need to create a Sitemap which starts with the landing page. After that you can continue with selector tree creation. Start by creating Url selectors for navigation links and pagination links. Then create an Element selector for a list item. And after that create Text selectors the items descriptors. The resulting Sitemap should look like the one in the image below. When your Sitemap is done you can start scraping it.
+
+![Selector tree][2]
+
+## Selectors
+
+There are different type of selectors for different type of data. Use this table to find a suited one for you. If there is not a selector that fits your needs, then you can try to create one. The scraper is built in a way that it is very easy to implement new selectors.
+
+Selector | Returned records | Returned data | Can lead to new Jobs | Can have child selectors
+--- | --- | --- | --- | ---
+Text | 1 or * | text | N | N
+Element | 1 or * | None | N | Y
+Group | 1 | JSON | N | N
+Link | 1 or * | text, url | Y | Y
+Image | 1 or * | image src | N | N
+
+### Text
+Used for text selection. All HTML will be stripped and only text will be returned. You can additionaly apply regex to resulting data. Regex is applied before data export so you can change the regex after data is scraped. If a link element is selected then also its href wttribute will be returned, but the scraper will not follow the link.
+
+### Element
+This selector will not return any data. Use this selector select multiple elements and add child selectors within this selector.
+
+### Group
+Use Group selector to select multiple items. The resulting items data will be seerialized as JSON and stored within one record.
+
+### Link
+Use this selector to select links. The scraper will follow links and select data from each child page.
+
+### Image
+Use this selector to retrieve image src attribute. The image itself will not be stored as it cannot be exported as CSV.
+
+## Issues
+Submit issues in issue tracker. Please attach an exported sitemap if possible.
+
+## License
+LGPLv3
+
+
+
+ [1]: http://www.youtube.com/
+ [2]: docs/images/sitemap-tree.png "sitemap-scraper.png"
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,2 @@
+http://jsfiddle.net/t8Sgq/
+http://jsfiddle.net/qpVkY/
Oops, something went wrong.

0 comments on commit 8937d80

Please sign in to comment.