Skip to content

Instantly share code, notes, and snippets.

@darkr4y
Created April 28, 2016 08:47
Show Gist options
  • Save darkr4y/d26076370f8097d83f8cb9a8f0e9d6cf to your computer and use it in GitHub Desktop.
Save darkr4y/d26076370f8097d83f8cb9a8f0e9d6cf to your computer and use it in GitHub Desktop.
easyicon download
#!/usr/bin/python
import sys
import urllib
import re
GetZipUrl = "http://www.easyicon.net/api/get_zip_api.php?id=" #1179177,1179178
def DownLoad(id):
url = GetZipUrl + id
u = urllib.urlopen(url)
print url
print u.info()
exit()
find_content = u.headers["Content-Disposition"]
find_keyword = "filename="
filename_pos = find_content.find(find_keyword)
filename = find_content[filename_pos + len(find_keyword):]
urllib.urlretrieve(GetZipUrl + id , filename)
'''
f = open(filename, 'wb')
meta = u.info()
file_size = int(meta.getheaders("Content-Length")[0])
file_size_dl = 0
block_sz = 8192
while True:
buffer = u.read(block_sz)
if not buffer:
break
file_size_dl += len(buffer)
f.write(buffer)
f.close()
'''
def EasyIconDownloader(strUrl):
rq = urllib.urlopen(strUrl)
rex = r'<a.*? title="(.*?)".*?>.*?</a>'
match = re.findall(rex, rq.read())
all_id = ""
if match:
for i in match:
if i.isdigit():
#print i
all_id += i + ","
else:
result = ""
#all_id[:-1]
DownLoad(all_id[:-1])
pass
if __name__ == "__main__":
EasyIconDownloader(sys.argv[1])
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment