Skip to content

Commit

Permalink
Update scraper.py
Browse files Browse the repository at this point in the history
  • Loading branch information
PascalRobichaudDO101 committed Jul 12, 2015
1 parent efabd6b commit 8f1bcf4
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions scraper.py
@@ -1,5 +1,17 @@
#Scraper pour le site FaireMTl.ca
#Version 3.0, 2015-07-12

# coding: utf8

#Fonction left
def left(s, amount = 1, substring = ""):
if (substring == ""):
return s[:amount]
else:
if (len(substring) > amount):
substring = substring[:amount]
return substring + s[:-amount]

import urllib
from bs4 import BeautifulSoup

Expand All @@ -22,6 +34,14 @@
# Afficher le nombre de commentaire
print("Nombre de commentaires: %s" % onglet_commentaires)

#2. Nombre d'abonnés
nombre_abonnes = soup.find_all('div',{'class':'pill js-subscribe_section_content'})
#print("Nombre d'abonnés: %s" % nombre_adonnes)
#foutput_debug.writerow(nombre_adonnes)
nombre_adonnes2 = nombre_abonnes[0].getText().strip()
position_espace = nombre_adonnes2.find(' ')
nombre_adonnes2 = left(nombre_adonnes2, position_espace - 1)
print("Nombre d'abonnés: %s" % nombre_adonnes2)

print('Fin du traitement')

Expand Down

0 comments on commit 8f1bcf4

Please sign in to comment.