Arquivo anexado 'pega_sf.py'
Download 1 #!/usr/bin/env python
2
3 import os
4 import re
5 from urllib import urlopen
6
7
8 sf_description_re = re.compile(r'<TD WIDTH="99%" VALIGN="top">\n<p>(.*?)<p>',re.M | re.S)
9
10 sf_links_txt = open('sf_py.txt')
11
12 sf_links = sf_links_txt.readlines()
13
14 sf_links_txt.close()
15
16 links_made = ''
17 if os.path.exists('sf_py_out.txt'):
18 print 'Excluindo os já feitos'
19 links_made = open('sf_py_out.txt').read()
20 links_ok = []
21 for link in links_made.split('\n'):
22 if link.startswith(' * ['):
23 project_link = link[6:link.find(']')]
24 print 'Ignorando:%s' % project_link
25 links_ok.append( project_link )
26 else:
27 print 'err:%s' % link
28
29
30 out_file = open('sf_py_out.txt','a')
31
32 for link in sf_links:
33 link = link[6:-2]
34 if link not in links_ok:
35 #Pega apenas o link
36
37 print "Reading page: %s" % link
38 sf_page = urlopen(link).read()
39 print "Pegando descrição..."
40 match = sf_description_re.search(sf_page)
41 if match is not None:
42 desc = match.groups()[0]
43 line = ' * [%s] - %s\n' % (link,desc)
44 out_file.write(line)
45 print line
46 else:
47 project_name = link.split('/')[-1]
48 debug_filename = 'sf_%s.debug' % project_name
49 debug_file = open(debug_filename,'w')
50 debug_file.write(sf_page)
51 debug_file.close()
52 print "Não consegui pegar a descrição de %s, escrito log em %s" % (project_name,debug_filename)
53
54
55
56 print 'done.'
57
Arquivos Anexados
Para se referir aos anexos de uma página, use attachment:filename, como mostrado abaixo na lista de arquivos. NÃO use a URL do link [get], já que a mesma está sujeita a alterações, e pode facilmente se tonar inválida.Você não tem permissão para anexar arquivos a esta página.