How store values together after scrape

I am able to scrape individual fields off a website, but would like to map the title to the time.

The fields "have their own class, so I am struggling on how to map the time to the title.

A dictionary would work, but how would i structure/format this dictionary so that it stores values on a line by line basis?

url for reference –

expected output:

9:00 AM-9:30 AM, Defining Race, Ethnicity, and Genetic Ancestry

11:00 AM-11:30 AM, Definitions of Structural Racism


from bs4 import BeautifulSoup
from selenium import webdriver
driver = webdriver.Chrome()
import time

page_source = driver.page_source

for item in productlist:
    for eachLine in item.find_all('a',href=True):
for t in times:

>Solution :

Selenium is an overkill here. Website didn’t use any dynamic content, so you can scrape it with Python requests and BeautifulSoup. Here is a code how to achieve it. You need to query productlist and times separately and then iterate using indexes to be able to get both items at once. I put in range() length of an productlist because I assuming that both productlist and times will have equal length.

import requests
from bs4 import BeautifulSoup

url = ''

res = requests.get(url)
soup = BeautifulSoup(res.content,'html.parser')

productlist ='div.itemtitle > a')
times ='.time')

for iterator in range(len(productlist)):
    row = times[iterator].text + ", " + productlist[iterator].text

Note: gather items by css.

Leave a Reply