iv class="bg-gray-800 p-4">
                    <pre>
import requests
import time
from bs4 import BeautifulSoup
import random
from fake_useragent import UserAgent

<span class="code-comment"># Create a session for maintaining cookies and headers</span>
session = requests.Session()

<span class="code-comment"># Set a random user agent</span>
ua = UserAgent()
session.headers.update({'User-Agent': ua.random})

<span class="code-comment"># Function to scrape with rate limiting and error handling</span>
def scra