-
Notifications
You must be signed in to change notification settings - Fork 0
/
README
53 lines (41 loc) · 2.02 KB
/
README
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
ResolveUrls.py: A small threaded url resolution utility, originally written for the
University of Illinois' Graduate School of Library and Information Science's TREC 2011
Microblog team.
Usage:
from ResolveUrls import UrlResolver
# Optional params and defaults: num_threads = 400, mysql_host = 'localhost', http_redirects = 10
resolver = UrlResolver(url_file = '~/urls.txt', mysql_user = 'root',
mysql_password = 'password', mysql_db = 'my_db')
resolver.run()
Alternate usage:
from ResolveUrls import ResolverThread
myQueue = Queue.Queue(maxsize=100)
for i in range(100):
# Optional params and defaults: mysql_host = 'localhost', http_redirects = 10
t = ResolverThread(myQueue, mysql_user = 'root', mysql_password = 'password',
mysql_db = 'my_db')
t.setDaemon(True)
t.start()
# Add your own logic here to add urls to the queue
...
urlQueue.put((url), block = True, timeout = None)
...
myQueue.join()
MySQL table structure:
resolved_urls
+---------------+---------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+---------------+---------------------+------+-----+---------+----------------+
| id | int(10) unsigned | NO | PRI | NULL | auto_increment |
| short_url | text | NO | | NULL | |
| response_code | int(11) | NO | | NULL | |
| long_url | text | YES | | NULL | |
| num_redirects | int(10) unsigned | YES | | NULL | |
+---------------+---------------------+------+-----+---------+----------------+
url_headers
+---------+---------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------+---------+------+-----+---------+-------+
| id | int(11) | NO | MUL | NULL | |
| headers | text | NO | | NULL | |
+---------+---------+------+-----+---------+-------+