-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfind-dotbot-repos
executable file
·48 lines (41 loc) · 1.16 KB
/
find-dotbot-repos
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
#!/usr/bin/env python3 -u
import re, time, os, sys
from urllib.request import urlopen
from urllib.error import HTTPError
SEARCH = '<p class="title">\n'
SLEEP_DUR = 5 # seconds
def page(n):
return '/~https://github.com/search?p=%d&q=%%22DOTBOT_DIR%%22&type=Code&utf8=%%E2%%9C%%93' % n
def listing():
if len(sys.argv) > 1:
return os.listdir(sys.argv[1])
else:
return os.listdir()
def check(name):
user = name[:name.find('/')]
if user != 'anishathalye':
modified = name.replace('/', '-')
if modified not in listing():
print(name)
def main():
num = 1
while True:
while True:
try:
req = urlopen(page(num))
except HTTPError:
time.sleep(SLEEP_DUR)
else:
break
text = req.read().decode('utf8')
locs = [m.start() for m in re.finditer(SEARCH, text)]
for loc in locs:
l = text.find('>', loc + len(SEARCH))
r = text.find('<', l)
name = text[l+1:r]
check(name)
num += 1
if len(locs) == 0:
break
if __name__ == '__main__':
main()