def setUp(self): template_string = """ <!DOCTYPE html> <head wp-name="head"> <title wp-name="title"/> </head> </html> """ self.scraper = weakscraper.WeakScraper(template_string)
def setUp(self): template_string = """ <!DOCTYPE html> <body> <tag1>a</tag1> <tag2>b</tag2> </body> </html> """ self.scraper = weakscraper.WeakScraper(template_string)
def setUp(self): template_string = """ <!DOCTYPE html> <body> <tag1>begining<wp-nugget wp-name="info1"/>middle<wp-nugget wp-name="info2"/>end</tag1> <tag2><wp-nugget wp-name="info3"/>end</tag2> </body> </html> """ self.scraper = weakscraper.WeakScraper(template_string)
def setUp(self): template_string = """ <!DOCTYPE html> <head> <title>Title</title> </head> <body attr1="val1" attr2="val2"> <div>Hi !</div> </body> </html> """ self.scraper = weakscraper.WeakScraper(template_string)
def setUp(self): template_string = """ <!DOCTYPE html> <body> <tag1 wp-optional> some text </tag1> <tag2 wp-name="tag2" wp-optional/> </body> </html> """ self.scraper = weakscraper.WeakScraper(template_string)
def setUp(self): template_string = """ <!DOCTYPE html> <body> <tag1>a</tag1> <wp-ignore wp-until="tag4"/> <tag4 attr1="value" wp-ignore-attrs>b</tag4> <tag5 wp-ignore-content/> <tag6 wp-ignore/> <wp-ignore/> </body> </html> """ self.scraper = weakscraper.WeakScraper(template_string)
def setUp(self): template_string = """ <!DOCTYPE html> <head wp-function="sum"> <number wp-name="a" wp-function="int"/> <number wp-name="b" wp-function="int"/> </head> </html> """ functions = { 'int': int, 'sum': (lambda dic: dic['a'] + dic['b']) } self.scraper = weakscraper.WeakScraper(template_string, functions)
def setUp(self): template_string = """ <!DOCTYPE html> <body> <div wp-function="sum" wp-list> <number wp-name="number" wp-function="int"/> </div> <number wp-function="str_sum" wp-list/> </body> </html> """ functions = { 'int': int, 'sum': (lambda l: sum([n['sum']['number'] for n in l])), 'str_sum': (lambda l: sum([int(n['str_sum']) for n in l])) } self.scraper = weakscraper.WeakScraper(template_string, functions)