xacnio/tweetcapture

support multiple urls

Closed this issue · 1 comments

i'm unable to download several tweets at once.

tweetcapture URL1 URL2 URL3

would it also be possible to support reading links from a text file?

Multithreading/concurrency required for this. It's possible by using different ports on chrome option for every thread. But It's not the job of the module. You can develop your concurrent tasks.

Example:

from tweetcapture import TweetCapture
import asyncio

async def taskCapture(url, port):
    tweet = TweetCapture()
    tweet.add_chrome_argument(f"--remote-debugging-port={port}")
    filename = await tweet.screenshot(url, overwrite=True)
    return filename

async def main():
    task1 = asyncio.create_task(taskCapture("https://twitter.com/jack/status/20", 9222))
    task2 = asyncio.create_task(taskCapture("https://twitter.com/Twitter/status/1445078208190291973", 9223))

    filename = await task1
    print(filename)
    filename2 = await task2
    print(filename2)


asyncio.run(main())

It can work simultaneously.


With a queue:

from tweetcapture import TweetCapture
import asyncio


async def main():
    tweet = TweetCapture()
    urls = ["https://twitter.com/jack/status/20", "https://twitter.com/Twitter/status/1445078208190291973"]

    for url in urls:
        await tweet.screenshot(url, overwrite=True)


asyncio.run(main())