FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
iScript/ed2k_search.py at master · banjin/iScript · GitHub
banjin
iScript
Repository navigation
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
iScript
/
ed2k_search.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
executable file
·
72 lines (58 loc) · 1.94 KB
Breadcrumbs
iScript
/
ed2k_search.py
Copy path
File metadata and controls
executable file
·
72 lines (58 loc) · 1.94 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
#!/usr/bin/env python2
# vim: set fileencoding=utf8
import
sys
import
urllib
import
re
import
argparse
s
=
'
\x1b
[%d;%dm%s
\x1b
[0m'
# terminual color template
opener
=
urllib
.
urlopen
class
ed2k_search
(
object
):
def
__init__
(
self
,
keyword
=
''
):
self
.
url
=
"http://donkey4u.com/search/%s?page=%s&mode=list"
\
%
(
keyword
,
'%s'
)
print
''
def
get_infos
(
self
,
url
):
r
=
opener
(
url
)
assert
r
self
.
html
=
r
.
read
()
html
=
re
.
search
(
r'<table class=\'search_table\'>.+?</table>'
,
self
.
html
,
re
.
DOTALL
).
group
()
sizes
=
re
.
findall
(
r'<td width=\'70\' align=\'right\'>(.+)'
,
html
)
seeds
=
re
.
findall
(
r'<td width=\'100\' align=\'right\'>(.+)'
,
html
)
links
=
re
.
findall
(
r'ed2k://.+?/'
,
html
)
infos
=
zip
(
sizes
,
seeds
,
links
)
if
infos
:
self
.
display
(
infos
)
else
:
print
s
%
(
1
,
91
,
' !! You are not Lucky, geting nothing.'
)
sys
.
exit
(
1
)
def
display
(
self
,
infos
):
template
=
' size: '
+
s
%
(
1
,
97
,
'%s'
) \
+
' seed: '
+
s
%
(
1
,
91
,
'%s'
) \
+
'
\n
----------------------------'
\
+
'
\n
'
+
s
%
(
2
,
92
,
'%s'
) \
+
'
\n
----------------------------
\n
'
for
i
in
infos
:
t
=
template
%
i
print
t
def
do
(
self
):
page
=
1
while
True
:
url
=
self
.
url
%
page
self
.
get_infos
(
url
)
nx
=
raw_input
(
s
%
(
1
,
93
,
' next page?'
)
+
' (N/y): '
)
if
nx
in
(
'Y'
,
'y'
):
page
+=
1
print
''
else
:
sys
.
exit
(
1
)
def
main
(
xxx
):
keyword
=
' '
.
join
(
xxx
)
x
=
ed2k_search
(
keyword
)
x
.
do
()
if
__name__
==
'__main__'
:
p
=
argparse
.
ArgumentParser
(
description
=
'searching ed2k at donkey4u.com'
)
p
.
add_argument
(
'xxx'
,
type
=
str
,
nargs
=
'*'
,
help
=
'keyword'
)
args
=
p
.
parse_args
()
main
(
args
.
xxx
)
Back
|
FazBrowse Home
|
New Git URL