Nov 19, 2019 03:32 PM
(This post was last modified: Nov 19, 2019 03:34 PM by 4ground_daemon.)
So I'm not sure how to exactly explain it but i'm wanting to build a bot that is going to scrape a load of blog websites to get check if they have made a new blog post since the last check I did. Now because the amount of sites I want to scrape is going to be a lot (looking at 50-100) I want a way to have each blog in its own module (as it will need its own functions to scrape the site) and all of these modules will be in a separate directory. So what I want in the end is for the bot to just import all the modules in that directory rather then having to hard code each on in which I know how to do)
my problem is how do I run the functions in each one of these imports because i'm not hard coding a name in? I basically want to go through each of the modules in that folder and then just run the functions in it.
To write it in pseudocode I would basically say:
-> import all modules in the /blogs directory
-> for each module in that directory run module_name.check()
-> check if latest blog post is new
-> if so return the url
But how do I reference module_name if i'm just importing all modules in that directory?
Also just to note. All the modules will have the same function names so there will be no problems with that.
Also just to clarify, another reason why I want it like this is to future proof it. It will allow me to just keep adding sites to the bot without having to touch the original file.
my problem is how do I run the functions in each one of these imports because i'm not hard coding a name in? I basically want to go through each of the modules in that folder and then just run the functions in it.
To write it in pseudocode I would basically say:
-> import all modules in the /blogs directory
-> for each module in that directory run module_name.check()
-> check if latest blog post is new
-> if so return the url
But how do I reference module_name if i'm just importing all modules in that directory?
Also just to note. All the modules will have the same function names so there will be no problems with that.
Also just to clarify, another reason why I want it like this is to future proof it. It will allow me to just keep adding sites to the bot without having to touch the original file.


