-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathcric.py
More file actions
52 lines (39 loc) · 920 Bytes
/
cric.py
File metadata and controls
52 lines (39 loc) · 920 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
from bs4 import BeautifulSoup
import requests
import os
#enter URL
url = "http://www.cricbuzz.com/cricket-match/live-scores"
req = requests.get(url)
data = req.text
soup = BeautifulSoup(data,'html.parser')
#using beautifulsoup for scraping
file = open("ci.txt","a")
for score in soup.findAll("div",{"class":"cb-lv-scrs-col"}):
#print score.text
scre = score.text
#scre in unicode form
scree = scre.encode('utf-8')
#encode it to convert in string form
#ss = os.path.split(s)
#print(type(s))
print scree
print '\n'
file.write(scree)
file.close()
#scoreIT = score.findAll('span')
#for scre in scoreIT:
# print scre.text
#score = soup.findAll("div",{"class":"cb-lv-scrs-col"})
#print score.text
#scre = score.text
#scree = scre.encode('utf-8')
#s = str(scree)
#ss = os.path.split(s)
#print(type(s))
#print ss
#print '\n'
#file.write(ss)
#file.close()
#else:
# print "hello"
print "completed"