4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the Revised BSD License.
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 Revised BSD License for more details.
12 Copyright 2014 Cool Dude 2k - http://idb.berlios.de/
13 Copyright 2014 Game Maker 2k - http://intdb.sourceforge.net/
14 Copyright 2014 Kazuki Przyborowski - https://github.com/KazukiPrzyborowski
16 $FileInfo: miss-bone.py - Last Update: 6/12/2014 Ver. 1.0.0 RC 2 - Author: cooldude2k $
33 fakeua
= "Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Firefox/24.0"
34 geturls_cj
= cookielib
.CookieJar()
35 geturls_opener
= urllib2
.build_opener(urllib2
.HTTPCookieProcessor(geturls_cj
))
36 geturls_opener
.addheaders
= [
38 "http://www.emoticonplus.com/miss-bone/"),
44 "en-US,en-CA,en-GB,en-UK,en-AU,en-NZ,en-ZA,en;q=0.5"),
46 "ISO-8859-1,ISO-8859-15,utf-8;q=0.7,*;q=0.7"),
48 "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"),
58 " Reading URL: http://www.emoticonplus.com/miss-bone/page/" +
60 geturls_text
= geturls_opener
.open(
61 "http://www.emoticonplus.com/miss-bone/page/" + str(i
))
62 if (geturls_text
.info().get("Content-Encoding") ==
63 "gzip" or geturls_text
.info().get("Content-Encoding") == "deflate"):
64 strbuf
= StringIO
.StringIO(geturls_text
.read())
65 gzstrbuf
= gzip
.GzipFile(fileobj
=strbuf
)
66 out_text
= gzstrbuf
.read()[:]
67 if (geturls_text
.info().get("Content-Encoding") !=
68 "gzip" and geturls_text
.info().get("Content-Encoding") != "deflate"):
69 out_text
= geturls_text
.read()[:]
70 regex_text
= re
.escape("<a class=\"emoticon-list\" href=\"#\" data=\"") + "(.*?)" + \
71 re
.escape("\" im=\"") + "([0-9]+)" + \
72 re
.escape("\" category=\"miss-bone\">")
73 post_text
= re
.findall(regex_text
, out_text
)
75 ilsub
= len(post_text
)
76 print(str(i
) + " Found " + str(ilsub
) + " GIF Images.")
78 getsub2xurls_cj
= geturls_cj
79 getsub2xurls_opener
= urllib2
.build_opener(
80 urllib2
.HTTPCookieProcessor(getsub2xurls_cj
))
81 getsub2xurls_opener
.addheaders
= [
83 "http://www.emoticonplus.com/miss-bone/page/" +
90 "en-US,en-CA,en-GB,en-UK,en-AU,en-NZ,en-ZA,en;q=0.5"),
92 "ISO-8859-1,ISO-8859-15,utf-8;q=0.7,*;q=0.7"),
94 "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"),
97 print(str(i
) + "," + str(isub
+ 1) + " Start Downloading Image File: " +
98 str(isub
+ 1) + " of " + str(ilsub
))
99 print(str(i
) + "," + str(isub
+ 1) +
100 " Downloading Image: " + post_text
[isub
][0])
101 getsub2xurls_text
= getsub2xurls_opener
.open(post_text
[isub
][0])
102 gif_file_name
= os
.path
.basename(
103 urlparse
.urlparse(post_text
[isub
][0]).path
)
104 print(str(i
) + "," + str(isub
+ 1) +
105 " Finished Downloading Image: " + post_text
[isub
][0])
106 print(str(i
) + "," + str(isub
+ 1) +
107 " Saving File: ./" + gif_file_name
)
108 gifsf
= open("./" + gif_file_name
, "wb")
109 gifsf
.write(getsub2xurls_text
.read())
112 sfcountsub
= sfcountsub
+ 1
113 print(str(i
) + " Downloaded " + str(sfcountsub
) + " GIF Images")
114 sfcountfull
= sfcountfull
+ sfcountsub
117 print("Downloaded " + str(sfcountfull
) + " GIF Images")