I get an error I somewhat understand but could not solve with the resources I found so far. What I want to do is to have a simple loop that takes a url from a list, requests its contents, prints the output, and goes on to the next url.
f = open('urls.txt','r',encoding="utf8") #had to specify encoding because of error: UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 3754: character maps to <undefined>
content_urls = f.readlines()
f.close()
from urllib import request
from bs4 import BeautifulSoup
import time
for each in content_urls:
time.sleep(1)
scraped = request.urlopen(content_urls)
soup = BeautifulSoup(scraped)
print(soup)
A "list" as previously mentioned seems to be the exact problem: AttributeError: 'list' object has no attribute 'timeout'
First searches brought me to: AttributeError: 'list' object has no attribute 'timeout' - Trying to process multiple URLs with BeautifulSoup Python list object has no attribute error 'list' object has no attribute 'timeout' and only prints first item in the table AttributeError: 'bytes' object has no attribute 'timeout'
But by all means, I seem to be unable to implement those solutions. Do I need to convert my list into a string? I did try so but it didn't seem to work out either.
Any help is much appreciated.