Save parts of a web site as pure text - Super User most recent 30 from superuser.com 2010-03-19T19:23:07Z http://superuser.com/feeds/question/74270 http://www.creativecommons.org/licenses/by-nc/2.5/rdf http://superuser.com/questions/74270/save-parts-of-a-web-site-as-pure-text 1 Save parts of a web site as pure text Martin http://superuser.com/users/10245 2009-11-23T14:41:56Z 2009-11-23T15:36:42Z <p>I hope I may ask this here.</p> <p>I need to extract the contents of an existing web site (in charge of the web site owner) to word (or text) documents. For this, I only need the content from one DIV with a given ID.</p> <p>Is there any tool for windows that can do this for me (ideally recursively)? I know wget and Web Site Downloader but both can "only" save the complete HTML.</p> http://superuser.com/questions/74270/save-parts-of-a-web-site-as-pure-text/74276#74276 0 Answer by joshhunt for Save parts of a web site as pure text joshhunt http://superuser.com/users/919 2009-11-23T14:46:30Z 2009-11-23T14:46:30Z <p>I do not think something like this already exists. I think your best option would be to code something up yourself.</p> <p><a href="http://www.crummy.com/software/BeautifulSoup/" rel="nofollow">BeautifulSoup</a> is a... beautiful Python library that will let you do this in very minimal code. For more help, I suggest you head over to <a href="http://stackoverflow.com/questions/tagged/beautifulsoup">Stack Overflow</a></p> http://superuser.com/questions/74270/save-parts-of-a-web-site-as-pure-text/74278#74278 1 Answer by eleven81 for Save parts of a web site as pure text eleven81 http://superuser.com/users/8544 2009-11-23T14:53:03Z 2009-11-23T15:36:42Z <p>Your best bet would be to build your own toolchain for this:</p> <ol> <li>Use a tool such as <code>wget</code> to recursively download the HTML files from which content is needed. Pay special attention to options <code>-r</code> to specify recursive downloading, and <code>-l</code> to specify depth of the recursion. <code>wget</code> outputs plain text.</li> <li>Use a tool such as <code>grep</code> to filter out everything except the line(s) containing the <code>&lt;DIV&gt;</code> you need. Pay special attention to options <code>-r</code> to specify recursive searching, and <code>-e</code> to specify a regular expression. Pipe <code>grep</code>'s output to a file of your choice. <code>grep</code> outputs plain text if it is fed plain text.</li> </ol> <p><strong>Hint:</strong> It may be simpler to use <code>grep</code> multiple times to filter out things in smaller chunks. This depends entirely on how similar all of the various pages are, and how clean the code is.</p> <p><hr></p> <p><strong>Edit:</strong> Then again, perhaps <a href="http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454">using a regex is <em>not</em> a good way to parse HTML</a>.</p> http://superuser.com/questions/74270/save-parts-of-a-web-site-as-pure-text/74280#74280 0 Answer by CarlF for Save parts of a web site as pure text CarlF http://superuser.com/users/11550 2009-11-23T14:58:51Z 2009-11-23T14:58:51Z <p>I'm lazy. In the time it would take you to research and set up a special-purpose tool, surely you can just highlight the required text with a mouse, copy it, and paste it into a text editor?</p>