How can i fix index out of range?

    import requests
from bs4 import BeautifulSoup
import csv
from itertools import zip_longest

result = requests.get("")
src = result.content
soup = BeautifulSoup(src, "lxml")

Job_title = []
Firm_name = []

Job_titles = soup.find_all("a", {"class":"css-nn640c"})
Firm_names = soup.find_all("a", {"class":"css-17s97q8"})

for i in range(len(Job_titles)):
    Filelist = [Job_title, Firm_name]
    Exported = zip_longest(*Filelist)

with open(r"C:\Users\****\Desktop\python\mydata.csv", "w") as myfile:
    wr = csv.writer(myfile)
    wr.writerow("Job title", "Company name")

Whats wrong with my code, it keeps generating this error" File "C:\Users****\PycharmProjects\pythonProject\Test1\", line 18, in Firm_name.append(Firm_names[i].text) IndexError: list index out of range

Read more here:

Content Attribution

This content was originally published by Gigiwan at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: