1

this is my code:

urls = [] 
uni_names = [] 
page_urls_new = [] 
university_details = ["Name","Link","Location","Rank"]

#Determine 
#Colleges 

start_time = int(round(time.time())) 

for i in range(0, len(page_urls)): 
    page_url = page_urls[i] 
    page_text_soup = BeautifulSoup(extract_source(page_url), "lxml") 
    entries = int(page_text_soup.find('strong', attrs={'data-test-id': 'total-items'}).text) 
    entries = int((entries / 20) + (0 if 0 == entries % 20 else 1))
1
  • 2
    It would be better if you format your code, so we can understand it. Also, provide more details of what's happening, and what did you expect to do. Commented Dec 10, 2021 at 18:31

1 Answer 1

2

Formatted the code on my side and you get this error because:

page_text_soup.find('strong', attrs={'data-test-id': 'total-items'})

returns None in your case, so when you try to access text attribute it will raise the attribute error.

Make sure the text you search for is present in your data, or enclose that line in a try/except block to handle this type of scenario.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.