Skip to content

Commit 1d18979

Browse files
committed
поправил parse.py
1 parent 8d9bea3 commit 1d18979

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

parse.py

+16-13
Original file line numberDiff line numberDiff line change
@@ -78,21 +78,24 @@ def revparser(self, url):
7878
server_status = Пингуем сервер по ip и получаем ответ True или False
7979
"""
8080
url_name = url[0]
81-
ip_port = urlparse(url[1]).netloc
82-
ip = ip_port.split(':')[0]
83-
port = ip_port.split(':')[1]
84-
name = urlparse(url[1]).path[1:]
81+
try:
82+
ip_port = urlparse(url[1]).netloc
83+
ip = ip_port.split(':')[0]
84+
port = ip_port.split(':')[1]
85+
except:
86+
ip = 'Uknown'
87+
port = 'Uknown'
88+
try:
89+
name = urlparse(url[1]).path[1:]
90+
except:
91+
name = 'Uknown'
8592
server_status = self.pinger(ip)
8693
try:
8794
page = requests.get(url[1], timeout=2)
8895
tree = html.fromstring(page.text)
8996
rev = max(tree.xpath('//td[@class="context-menu-revision"]/@rev'))
90-
except (requests.ConnectionError, lxml.etree.XMLSyntaxError):
97+
except (requests.ConnectionError, lxml.etree.XMLSyntaxError, ValueError, requests.RequestException):
9198
rev = 'Uknown'
92-
except ValueError:
93-
rev = 'Uknown'
94-
ip = 'Uknown'
95-
port = 'Uknown'
9699
return [url_name, ip, port, name, rev, server_status]
97100

98101
def testingTest(self):
@@ -139,9 +142,9 @@ def resourcesRes(self):
139142

140143
if __name__ == '__main__':
141144
p = Parser()
142-
print(p.testingTest())
143-
print(p.testingBuild())
145+
# print(p.testingTest())
146+
# print(p.testingBuild())
144147
print(p.testingDoc())
145148
print(p.testingMerge())
146-
print(p.camerasCam())
147-
print(p.resourcesRes())
149+
# print(p.camerasCam())
150+
# print(p.resourcesRes())

0 commit comments

Comments
 (0)