forked from flipkart-incubator/watchdog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
parser.py
executable file
·45 lines (35 loc) · 945 Bytes
/
parser.py
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
import requests
from bs4 import BeautifulSoup
import os
import pprint
import sys
inp = str(sys.argv[1])
f = open(inp)
soup = BeautifulSoup(f.read(),"lxml")
table = soup.find_all("div",{"id":"\\\"issue_types\\\""})
table = BeautifulSoup(str(table),"lxml")
data = table.find_all("table")
categories = []
catFile = open("categories.txt")
catFile = catFile.read()
requiredCategories = catFile.split("\n")
finalCount = 0
for issue in table:
issue = BeautifulSoup(str(issue),"lxml")
datasList = issue.find_all("td")
# print len(datas)
for datas in datasList:
try:
tr = BeautifulSoup(str(datas),"lxml")
name = tr.find_all("span")[0]
count = tr.find_all("span")[1]
Name = name.string
Count = count.string.split("(")[1].split(")")[0]
categories.append({"name":Name,"count":Count})
except:
pass
for i in categories:
for j in requiredCategories:
if(i["name"]==j):
finalCount += int(i["count"])
print finalCount