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

Method feed

recipes/Python/286269_HTML_Scraper/recipe-286269.py:56–81  ·  view source on GitHub ↗

Pass more data into the parser. As much as possible is processed - but nothing is returned from this method.

(self, data)

Source from the content-addressed store, hash-verified

54 return data
55
56 def feed(self, data):
57 """Pass more data into the parser.
58 As much as possible is processed - but nothing is returned from this method.
59 """
60 self.index = -1
61 self.tempindex = 0
62 self.buffer = self.buffer + data
63 outlist = []
64 thischunk = []
65 while self.index < len(self.buffer)-1: # rewrite with a list of all the occurences of '<' and jump between them, much faster than character by character - which is fast enough to be fair...
66 self.index += 1
67 inchar = self.buffer[self.index]
68 if inchar == '<':
69 outlist.append(self.pdata(''.join(thischunk)))
70 thischunk = []
71 result = self.tagstart()
72 if result: outlist.append(result)
73 if self.tempindex: break
74 else:
75 thischunk.append(inchar)
76 if self.tempindex:
77 self.buffer = self.buffer[self.tempindex:]
78 else:
79 self.buffer = ''
80 if thischunk: self.buffer = ''.join(thischunk)
81 self.outfile = self.outfile + ''.join(outlist)
82
83 def tagstart(self):
84 """We have reached the start of a tag.

Callers 10

stripHTMLFunction · 0.45
getMungedMessageFunction · 0.45
stripMethod · 0.45
recipe-284631.pyFile · 0.45
recipe-135005.pyFile · 0.45
recipe-286269.pyFile · 0.45
recipe-275370.pyFile · 0.45
recipe-224043.pyFile · 0.45
recipe-259097.pyFile · 0.45
mirrorMethod · 0.45

Calls 4

pdataMethod · 0.95
tagstartMethod · 0.95
appendMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected