def start(): parser.publish_report('main/articles.json', crawler.find_articles( crawler.get_html_page('https://novayagazeta.ru/stories').text)) with open("main/articles.json", "r") as read_file: data = json.load(read_file) link = data["url"] articles = data["articles"] return render_template('report.html', link=link, list=articles)
def start(): crawler.publish_report( 'data_file.json', crawler.find_articles( crawler.get_html_page('https://sobesednik.ru/psychology'))) with open("data_file.json", "r") as read_file: data = json.load(read_file) link = data["url"] articles = data["articles"] return render_template('template.html', link=link, list=articles)
def test_structure(self): artjson = crawler.publish_report( 'data_file.json', crawler.find_articles( crawler.get_html_page('https://sobesednik.ru/psychology'))) self.assertEqual(artjson["url"] == "", False)
def test_allHeaders(self): with open("psychologyNews.html", "r", encoding='utf-8') as read_file: self.assertEqual(len(crawler.find_articles(read_file)), 35)