I'm using my crawler class in the following manner and I'm beginning to think it's bad practice:
crawler.py
import requests
class Crawler():
def __init__(self, url):
self.url = url
def web_crawler(self):
requests.get(self.url)
return requests.text
main.py
for url in urls:
crawler = Crawler(url)
results = crawler.web_crawler()
Would it be better to move the url
parameter outside of Crawler
's __init__
and move it into the web_crawler
function? That way the class won't have to be reinitialized multiple times in main.py.
return requests.text
? Did you, at least, tried to run this code? \$\endgroup\$