-
Notifications
You must be signed in to change notification settings - Fork 3
/
app_list.py
34 lines (31 loc) · 1019 Bytes
/
app_list.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
from xml.dom import minidom
import requests
urls = []
res = requests.get('https://cafebazaar.ir/app-sitemap.xml')
xmldoc = minidom.parseString(res.text)
itemlist = xmldoc.getElementsByTagName('loc')
for s in itemlist:
#if str(s.childNodes[0].nodeValue).split('/')[3].split('-')[2] == 'fa':
print(s.childNodes[0].nodeValue)
urls.append(s.childNodes[0].nodeValue)
apps = []
for url in urls:
print(url)
try:
res = requests.get(url)
except requests.exceptions.ConnectionError:
try:
while res.status_code != 200:
res = requests.get(url)
except:
pass
print(res.status_code)
xmldoc = minidom.parseString(res.text)
itemlist = xmldoc.getElementsByTagName('loc')
for s in itemlist:
#print((s.childNodes[0].nodeValue).split('/')[4])
apps.append((s.childNodes[0].nodeValue).split('/')[4])
with open("apps.txt", "a") as myfile:
for app in apps:
myfile.write(app)
myfile.write('\n')