Hello! I'm making a web scraper using a JSON config file. In my config file, I can have multiple objects representing a website. With multiple URLs if needed. I want to create a thread that will download the HTML of the given website for each object inside my config file simultaneously. Let me be more precise:
Here's my config file:
{
"websites": [
{
"id": "example",
"name": "example of a website object",
"urls": [
"https://example.com",
"https://example2.com"
]
},
{
"id": "example2",
"name": "example of a website object2",
"urls": [
"https://example.com",
"https://example2.com"
]
}
]
}
In my scraper, I get all objects from the website vec and iterate through it, and for each object, I want to create a thread. But I don't know how, I'm not comfortable with a loop in rust... For now, I just have something like that:
for website in &websites {
download_thread(website);
}
But it will not create threads simultaneously but one after another, so it's not what I want.