summaryrefslogtreecommitdiffstats
path: root/chrome/test/data/safe_browsing/download_update.py
blob: bef5c6d6d8425827b10c1f3c6c476e5ae0fa318a (plain)
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
#!/usr/bin/python

import urllib,sys


url = 'http://safebrowsing.clients.google.com/safebrowsing/downloads?client=googleclient&appver=1.0&pver=2.1'

if len(sys.argv) == 1:
  data = 'goog-phish-shavar;\ngoog-malware-shavar;\n'
else:
  post_data_file = sys.argv[1]
  file = open(post_data_file, "r")
  data = file.read()
  file.close

response = urllib.urlopen(url, data)

response_file = open("response", "r+")
response_file.write(response.read())
response_file.seek(0)

counter = 0

for line in response_file:
  if not line.startswith('u:'):
    continue

  chunk_url = 'http://' + line[2:]
  filename = chunk_url[chunk_url.rfind('/') + 1:]
  filename =  "%03d" % counter + filename[0:filename.rfind('_')]
  counter += 1

  urllib.urlretrieve(chunk_url, filename)

response_file.close()