forked from tanjiti/sec_profile
-
Notifications
You must be signed in to change notification settings - Fork 1
/
get_real_url.py
63 lines (53 loc) · 1.69 KB
/
get_real_url.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
# -*- coding: utf-8 -*-
import sys
reload(sys)
sys.setdefaultencoding('utf8')
from mills import get_redirect_url
from mills import SQLiteOper
def get_real_url(so, renew=False, proxy=None, retry=3, timeout=10):
"""
:param so:
:return:
"""
urls = {
"secwiki": set(),
"xuanwu": set()
}
if proxy is not None:
sql = "select distinct url from xuanwu_detail where " \
"root_domain ='t.co' " \
"or root_domain='bit.ly' " \
"or root_domain='goo.gl' " \
"or root_domain='ow.ly' " \
"or root_domain='bddy.me' " \
"or root_domain='buff.ly' " \
"or root_domain='intel.ly'" \
"or root_domain='symc.ly' " \
"or root_domain='ht.ly' "
result = so.query(sql)
for item in result:
item = item[0]
if item:
urls['xuanwu'].add(item)
sql = "select distinct url from secwiki_detail where root_domain = 'dwz.cn' "
result = so.query(sql)
for item in result:
item = item[0]
urls['secwiki'].add(item)
for k, v in urls.items():
for vv in v:
sql = get_redirect_url(vv, proxy=proxy,
root_dir="data/shorturl",
isnew=renew, retry=retry,
timeout=timeout,
source=k)
if sql:
so.execute(sql)
print k, vv, sql
if __name__ == "__main__":
"""
"""
proxy = None
so = SQLiteOper("data/scrap.db")
# 获取短链接真实url
get_real_url(so, renew=False, proxy=proxy)