Save parts of a web site as pure text - Super User most recent 30 from superuser.com2010-03-19T19:23:07Zhttp://superuser.com/feeds/question/74270http://www.creativecommons.org/licenses/by-nc/2.5/rdfhttp://superuser.com/questions/74270/save-parts-of-a-web-site-as-pure-text1Save parts of a web site as pure textMartinhttp://superuser.com/users/102452009-11-23T14:41:56Z2009-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#742760Answer by joshhunt for Save parts of a web site as pure textjoshhunthttp://superuser.com/users/9192009-11-23T14:46:30Z2009-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#742781Answer by eleven81 for Save parts of a web site as pure texteleven81http://superuser.com/users/85442009-11-23T14:53:03Z2009-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><DIV></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#742800Answer by CarlF for Save parts of a web site as pure textCarlFhttp://superuser.com/users/115502009-11-23T14:58:51Z2009-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>