def assertValidSERP(self, url, expected_engine_name, expected_keyword, **kwargs): # Test both the URL and a parsed URL version for url in (url, urlparse(url)): res = extract(url, **kwargs) self.assertEqual(res.keyword, expected_keyword) self.assertEqual(res.engine_name, expected_engine_name) self.assertTrue(is_serp(url, **kwargs))
def assertInvalidSERP(self, url, **kwargs): result = extract(url, **kwargs) if result: self.assertIsNotNone(result.engine_name) self.assertEqual(result.keyword, '') self.assertTrue(is_serp(url, **kwargs)) else: self.assertIsNone(result) self.assertFalse(is_serp(url, **kwargs))
def main(csv_file_name): """Read lines from csv file formatted as <i>,<url> and output results to console.""" serps = 0 nonserps = 0 with open(csv_file_name, 'r') as f: reader = csv.reader(f) for i, url in reader: result = extract(url) is_serp = result is not None if is_serp: serps += 1 else: nonserps += 1 print('{},{},{},{},{}'.format( i, is_serp, result.engine_name if is_serp else None, result.keyword if is_serp else None, url).encode(encoding='utf-8')) print('Total SE: {}, non-SE: {}'.format(serps, nonserps))
def main(csv_file_name): """Read lines from csv file formatted as <i>,<url> and output results to console.""" serps = 0 nonserps = 0 with open(csv_file_name, 'r') as f: reader = csv.reader(f) for i, url in reader: result = extract(url) is_serp = result is not None if is_serp: serps += 1 else: nonserps += 1 print('{},{},{},{},{}'.format(i, is_serp, result.engine_name if is_serp else None, result.keyword if is_serp else None, url).encode(encoding='utf-8')) print('Total SE: {}, non-SE: {}'.format(serps, nonserps))
def assertInvalidSERP(self, url, **kwargs): self.assertIsNone(extract(url, **kwargs)) self.assertFalse(is_serp(url, **kwargs))
def assertValidSERPs(self, expected_serps): for url, engine_name, keyword in expected_serps: res = extract(url) assert res.keyword == keyword assert res.engine_name == engine_name