In your code, something strange is going on, corrected:
import requests from bs4 import BeautifulSoup class PageDownload: def __init__(self, urls): self.urls = urls def taking_things(self): for url in self.urls: s = requests.get(url) b = BeautifulSoup(s.content, 'html.parser') self.title = b.select_one('head > title') print(self.title) urls = ['https://www.sima-land.ru/kanctovary/shkolnye-tovary/opticheskie-pribory/', 'https://wmasteru.org/threads/Простой-парсер-товаров-с-amazon-с-помощью-beautifulsoup.22880/'] p = PageDownload(urls) p.taking_things()
See:
class PageDownload(urls): - in brackets after the class name indicates the type from which that is inheriteddef ___init___(self): - here is a typo 3 underscores, instead of two
Ps.
I would also recommend replacing:
b = BeautifulSoup(s.text) to b = BeautifulSoup(s.content) , and preferably with a parser, for example: b = BeautifulSoup(s.content, "html.parser") or b = BeautifulSoup(s.content, "lxml")
And the select itself looks strange - the soup element should not be on that page, and you want to take the title of the page from the title tag, then: title = b.select('head > title')
Pps
Regarding the error, I wondered why it came out this way and sketched a small example:
class Foo: def __init__(self, *args, **kwargs): print('__init__:\nargs={}\nkwargs={}'.format(args, kwargs)) urls = Foo() print() class PageDownload(urls): def __init__(self, urls): self.urls = urls
Console:
__init__: args=() kwargs={} __init__: args=('PageDownload', (<__main__.Foo object at 0x000001D2FE773F60>,), {'__module__': '__main__', '__qualname__': 'PageDownload', '___init___': <function PageDownload.___init___ at 0x000001D2FE7782F0>}) kwargs={}
As can be seen from the console, the code called upon inheritance passes several parameters to the constructor.
It turns out that the TypeError: list expected at most 1 arguments, got 3 error TypeError: list expected at most 1 arguments, got 3 occurred when more parameters were passed to the list constructor than the one calculated - i.e. 1 parameter was expected, and 3 was received.