How to save webpages text content as a text file using python
<p>I did python script:</p>

<pre><code>    from string import punctuation
    from collections import Counter
    import urllib
    from stripogram import html2text
    myurl = urllib.urlopen("https://www.google.co.in/?gfe_rd=cr&amp;ei=v-PPV5aYHs6L8Qfwwrlg#q=samsung%20j7") 
    html_string = myurl.read()
    text = html2text( html_string )
    file = open("/home/nextremer/Final_CF/contentBased/contentCount/hi.txt", "w")
    file.write(text)
    file.close()
</code></pre>

<p>Using this script I didn't get perfect output only some HTML code.<br>
      <li>  I want save all webpage text content in a text file.<br>
      <li>  I used urllib2 or bs4 but I didn't get results.<br>
      <li> I don't want output as a html structure.
<li>I want all text data from webpage</p>

<p>You dont need to write any hard algorithms to extract data from search result. Google has a API to do this.<br>
Here is an example:<br><a href="https://github.com/google/google-api-python-client/blob/master/samples/customsearch/main.py" rel="nofollow">https://github.com/google/google-api-python-client/blob/master/samples/customsearch/main.py</a><br>
But to use it, first you must to register in google for API Key.<br>
All information you can find here:<br> <a href="https://developers.google.com/api-client-library/python/start/get_started" rel="nofollow">https://developers.google.com/api-client-library/python/start/get_started</a></p>

python