File tree 2 files changed +31
-0
lines changed
2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -43,3 +43,9 @@ Happy scripting!
43
43
#### Requirements :
44
44
45
45
Python 3.5+
46
+
47
+ ### WebWordCounter
48
+ A simple script that counts how many times a word appears on a web page
49
+
50
+ ### Requirements :
51
+ Python 3.5+
Original file line number Diff line number Diff line change
1
+ #!/usr/bin/env python
2
+ # -*- coding: utf-8 -*-
3
+ import requests
4
+ import sys
5
+
6
+ def contador (link , palavra ):
7
+ print ("Bem vindo ao contador de palavra" )
8
+ print ()
9
+ link = sys .argv [1 ]
10
+ palavra = sys .argv [2 ]
11
+ while True :
12
+ try :
13
+ r = requests .get (link )
14
+ texto = r .text .lower ()
15
+ contador = texto .count (palavra .lower ())
16
+ print ()
17
+ print ('{} aparece {} vezes em {}' .format (palavra , contador , link ))
18
+ break
19
+ except (requests .exceptions .ConnectionError , IndexError ):
20
+ print ('O link informado é inválido, verifique-o e tente novamente.' )
21
+ break
22
+ except requests .exceptions .MissingSchema :
23
+ print ('Por favor insira http(s) antes do seu link.' )
24
+ break
25
+ contador (sys .argv [1 ], sys .argv [2 ])
You can’t perform that action at this time.
0 commit comments