MCPcopy Create free account
hub / github.com/ActiveState/code / download_others

Function download_others

recipes/Python/522983_comixGetter/recipe-522983.py:34–68  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

32#
33#===============================
34def download_others():
35
36 cnxn = connect('www.archiecomics.com')
37
38 print "getting: Archie"
39
40 cnxn.request("GET", '/')
41
42 res = cnxn.getresponse()
43
44 p = re.match(re_date, res.getheader("date"))
45
46 comic_path = '/pops_shop/dailycomics/image' + p.group(1) + '.gif'
47
48 #reconnecting since archiecomics.com closes connection after sending response
49 cnxn = connect('www.archiecomics.com')
50
51 cnxn.request("GET", comic_path)
52
53 res = cnxn.getresponse()
54
55 igot = res.status, res.reason
56
57 if res.status != "200" and res.reason != "OK":
58 print 'continuing to next comic since i got: '
59 print igot
60 return
61
62 f = open('archie'+"_"+p.group(1)+"_"+p.group(2)+"_"+p.group(3)+".gif", "wb")
63
64 f.write(res.read())
65
66 f.close()
67
68 print "OK"
69
70#===============================
71#connect(server) - connect to server

Callers 1

recipe-522983.pyFile · 0.85

Calls 9

connectFunction · 0.70
openFunction · 0.50
requestMethod · 0.45
matchMethod · 0.45
getheaderMethod · 0.45
groupMethod · 0.45
writeMethod · 0.45
readMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected