Connect to an already running Nitter instance
pluja opened this issue · 1 comments
pluja commented
Would it be possible to use this connecting to an already running Nitter instance?
pluja commented
I solved this.
I added a new variable (container_name) to nitter.py
file:
host: IPv4Address
port: int
container_name: str
I added this function to my nitter.py
file:
def get(self):
client = self._get_client()
self.container = client.containers.get(
container_id=self.container_name
)
logger.info(f"Got container {self.container.name} {self.container.short_id}. Status {self.container.status} at {self.address}.")
And the context manager looks like this:
@contextmanager
def NitterScraper(host: str = "0.0.0.0", port: int = 8008, container_name: str = "ff1fc8e9f922"):
"""The NitterScraper context manager.
Takes care of configuring, starting, and stopping a docker instance of nitter.
Args:
host: The host address the docker container will bind too.
port: The port the docker container will listen to.
container_name: The name or id of the container to connect.
Yields:
Nitter: An object representing a started nitter docker container.
"""
nitter = Nitter(host=host, port=port, container_name=container_name)
nitter.get()
yield nitter