Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @staticmethod
- def get_videos(topic):
- """
- Get all the videos in the photos section
- :param topic:
- :return:
- """
- if topic != 'videos':
- raise ValueError('Topic should be videos')
- topic_url = DailyNation.BASE_URL + DailyNation.get_topics_url()[topic.lower()]
- html = DailyNation.get_html(topic_url)
- if html:
- videos = {}
- videos_list_div = html.find('div', class_='cb-content videolist')
- videos_topics = videos_list_div.find_all('div', class_='vh-caption')
- videos_caption_headings = []
- for caption_div in videos_topics:
- videos_caption_headings.append(DailyNation.clean_string(caption_div.find('h3').text))
- video_rows_divs = videos_list_div.find_all('div', class_='row')
- videos_caption_headings_count = 0
- for videos_item_div in video_rows_divs:
- trs = videos_item_div.find('table').find_all('tr')
- items = []
- for tr in trs:
- tds = tr.find_all('td')
- for td in tds:
- items.append({
- 'caption': td.find('div', class_='v-desc').text,
- 'image_url': td.find('div', class_='v-img').find('img').get('src'),
- 'story_url': DailyNation.BASE_URL + td.find(
- 'div',
- class_='col-lg-3 col-xs-12 col-sm-6 videoitem'
- ).find('a').get('href')
- })
- videos[videos_caption_headings[videos_caption_headings_count]] = items
- videos_caption_headings_count += 1
- return videos
Add Comment
Please, Sign In to add comment