i want to scrape data using python script
<p>I have written python script to scrape data from <a href="http://www.cricbuzz.com/cricket-stats/icc-rankings/batsmen-rankings" rel="nofollow">http://www.cricbuzz.com/cricket-stats/icc-rankings/batsmen-rankings</a> 
It is a list of 100 players and I successfully scraped this data. The problem is, when i run script instead of scraping data just one time it scraped the same data 3 times.</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="cb-col cb-col-100 cb-font-14 cb-lst-itm text-center"&gt;
  &lt;div class="cb-col cb-col-16 cb-rank-tbl cb-font-16"&gt;1&lt;/div&gt;
  &lt;div class="cb-col cb-col-50 cb-lst-itm-sm text-left"&gt;
    &lt;div class="cb-col cb-col-33"&gt;
      &lt;div class="cb-col cb-col-50"&gt;
        &lt;span class=" cb-ico" style="position:absolute;"&gt;&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;â
      &lt;/div&gt;
      &lt;div class="cb-col cb-col-50"&gt;
        &lt;img src="http://i.cricketcb.com/i/stats/fw/50x50/img/faceImages/2250.jpg" class="img-responsive cb-rank-plyr-img"&gt;
      &lt;/div&gt;
    &lt;/div&gt;
    &lt;div class="cb-col cb-col-67 cb-rank-plyr"&gt;
      &lt;a class="text-hvr-underline text-bold cb-font-16" href="/profiles/2250/steven-smith" title="Steven Smith's Profile"&gt;Steven Smith&lt;/a&gt;
      &lt;div class="cb-font-12 text-gray"&gt;AUSTRALIA&lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="cb-col cb-col-17 cb-rank-tbl"&gt;906&lt;/div&gt;
  &lt;div class="cb-col cb-col-17 cb-rank-tbl"&gt;1&lt;/div&gt;
&lt;/div&gt;</code></pre>
</div>
</div>
</p>

<p>And here is python script which i write scrap each player data.</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>import sys,requests,csv,io
from bs4 import BeautifulSoup
from urllib.parse import urljoin

url = "http://www.cricbuzz.com/cricket-stats/icc-rankings/batsmen-rankings"
r = requests.get(url)
r.content
soup = BeautifulSoup(r.content, "html.parser")

maindiv = soup.find_all("div", {"class": "text-center"})
for div in maindiv:
	print(div.text)</code></pre>
</div>
</div>
</p>

<p>but instead of scraping the data once, it scrapes the same data 3 times.</p>

<p>Where can I make changes to get data just one time?</p>

<p>The reason you get output three times is because the website has three categories you have to select it and then accordingly you can use it.</p>

<p>Simplest way of doing it with your code would be to add just one line</p>

<pre><code>import sys,requests,csv,io
from bs4 import BeautifulSoup

url = "http://www.cricbuzz.com/cricket-stats/icc-rankings/batsmen-   rankings"
r = requests.get(url)
r.content
soup = BeautifulSoup(r.content, "html.parser")

specific_div = soup.find_all("div", {"id": "batsmen-tests"})
maindiv = specific_div[0].find_all("div", {"class": "text-center"})
for div in maindiv:
    print(div.text) 
</code></pre>

<p>This will give similar reuslts with just test batsmen, for other output just change the "id" in specific_div line.</p>

python html5 python-3.x beautifulsoup python-3.4