-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsocials.py
executable file
·171 lines (144 loc) · 4.79 KB
/
socials.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
#!/usr/bin/env python3
# SADIK KUZU (c) 2020
# http://ctrl-c.club/~sadikkuzu/socials.html
import datetime
import os
import re
import requests
twitter = []
instagram = []
mastodon = []
github = []
found = []
def ayikla(adresler):
for adres in adresler:
try:
r = requests.get("https://" + adres.split("https://")[-1])
if r.status_code != 200:
adresler.remove(adres)
except Exception:
adresler.remove(adres)
def baloncuksort(liste, balon):
l2 = list()
g = (item for item in liste if item["username"] == str(balon))
while True:
try:
l2.append(next(g))
except Exception:
break
g = (item for item in liste if item["username"] != str(balon))
while True:
try:
l2.append(next(g))
except Exception:
break
return l2
def olustur(liste):
adi = [k for k, v in globals().items() if v == liste][0]
harf = adi[0].upper()
print(f"<strong>[*] {str(adi)}</strong> ({str(len(liste))})<br>")
for item in liste:
print(
f"[{str(harf)}] <a href=\"https://{item['url']}\" target=\"blank\""
f">{item['url']}</a> (<a href=\"http://ctrl-c.club/~"
f"{item['username']}\" target=\"_blank\">~{item['username']}"
f"</a>)<br>",
)
print("<br><br>")
def main():
global twitter
global instagram
global mastodon
global github
global found
for filename in os.listdir("/home"):
s = ""
try:
s = open(f"/home/{filename}/public_html/index.html").read()
except Exception:
continue
tw = re.findall(r"twitter\.com\/[a-z0-9A-Z_]+", s)
ma = re.findall(r"[a-zA-Z0-9\.]+\/@[a-z0-9A-Z_]+", s)
ig = re.findall(r"instagram\.com\/[a-z0-9A-Z._]+", s)
gh = re.findall(r"https://github\.com\/[a-z0-9A-Z_]+", s)
ayikla(tw)
# ayikla(ma)
# ayikla(ig)
ayikla(gh)
if len(tw):
for item in tw:
if item not in found and item != "twitter.com/widgets":
twitter.append(
{
"url": item,
"username": filename,
},
)
found.append(item)
if len(ma):
for item in ma:
if item not in found and "medium.com" not in item:
mastodon.append(
{
"url": item,
"username": filename,
},
)
found.append(item)
if len(ig):
for item in ig:
if item not in found:
instagram.append(
{
"url": item,
"username": filename,
},
)
found.append(item)
if len(gh):
for item in gh:
if item not in found and "/elm" not in item:
github.append(
{
"url": item.split("https://")[-1],
"username": filename,
},
)
found.append(item)
bubble = "sadikkuzu"
github = baloncuksort(github, bubble)
twitter = baloncuksort(twitter, bubble)
mastodon = baloncuksort(mastodon, bubble)
instagram = baloncuksort(instagram, bubble)
print(
'<html><body><link href="https://'
'fonts.googleapis.com/css?family=Roboto+Mono:300,700" rel="style'
'sheet"><style type="text/css">body {background-color:#1C1C1C;color: '
'#fff;font-family: "Roboto Mono", "Hack", "Inconsolata", monospace;'
"}a{color:#00AAEE;}</style>",
)
simdi: str = str(datetime.datetime.now())
print(f"[*] <strong>Updated at :</strong> {simdi}<br>")
total_count = len(github) + len(twitter) + len(mastodon) + len(instagram)
print(f"[*] <strong>Total count:</strong> {total_count}<br><br>")
olustur(github)
olustur(twitter)
olustur(mastodon)
olustur(instagram)
print(
"This page is inspired by "
'<a href="http://ctrl-c.club/~0x00ctrl" target="_blank">'
"~0x00ctrl</a>'s "
'<a href="http://ctrl-c.club/~0x00ctrl/social.html" target="_blank">'
"social</a> page.<br/>",
)
print(
'<a href="https://github.com/sadikkuzu/ctrl-c-club'
'/blob/master/socials.py"'
' target="_blank">Developed</a> by <a '
'href="http://ctrl-c.club/~sadikkuzu" target="blank">~sadikkuzu</a>',
)
print("</body></html>")
return 0
if __name__ == "__main__":
raise SystemExit(main())