-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
35 lines (31 loc) · 1.11 KB
/
test.py
File metadata and controls
35 lines (31 loc) · 1.11 KB
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
import requests
from BeautifulSoup import BeautifulSoup, SoupStrainer
import re
response = requests.get('http://www.metamodsource.net/downloads/').content
links = []
for l in BeautifulSoup(response, parseOnlyThese=SoupStrainer('a')):
links.append(l['href'])
links_list = []
for link in links:
match = re.match(r'(?im)^\/downloads\/mmsource-(.+?)-(windows\.zip|linux\.tar\.gz|mac\.zip)$', link)
if match:
links_list.append(match.group())
linux, windows, mac = None, None, None
for link in links_list:
links = []
response = requests.get('http://www.metamodsource.net'+link).content
for l in BeautifulSoup(response, parseOnlyThese=SoupStrainer('a')):
links.append(l['href'])
for line in links:
match = re.match(r'(?im)^http:(.+?)-(windows\.zip|linux\.tar\.gz|mac\.zip)$', line)
if match:
if match.group().find('windows') != -1:
windows = match.group()
if match.group().find('linux') != -1:
linux = match.group()
else:
mac = match.group()
break
print mac
print windows
print linux