Python: (Beautifulsoup) How to limit extracted text from a html news article to only the news article.
<p>I wrote this test code which uses BeautifulSoup.</p>

<pre><code>url = "http://www.dailymail.co.uk/news/article-3795511/Harry-Potter-sale-half-million-pound-house-Iconic-Privet-Drive-market-suburban-Berkshire-complete-cupboard-stairs-one-magical-boy.html"    
html = urllib.request.urlopen(url).read()  
soup = BeautifulSoup(html,"lxml")
for n in soup.find_all('p'):
    print(n.get_text())
</code></pre>

<p>It works fine but it also retrieves text that is not part of the news article, such as the time it was posted, number of comments, copyrights ect. </p>

<p>I would wish for it to only retrieve text from the news article itself, how would one go about this? </p>

<p>You'll need to target more specifically than just the <code>p</code> tag. Try looking for a <code>div class="article"</code> or something similar, then only grab paragraphs from there</p>

python html beautifulsoup