My program needs to do 2 things.
Extract stuff from a webpage.
Do stuff with a webpage.
However, there are many webpages, su
It's up to you. I personally try to stay away from Java-style classes when programming in python. Instead, I use dicts and/or simple objects.
For instance, after defining these functions (the ones you defined in the question), I'd create a simple dict, maybe like this:
{ 'facebook' : { 'process' : facebookProcess, 'extract': facebookExtract },
.....
}
or, better yet, use introspection to get the process/extract function automatically:
def processor(sitename):
return getattr(module, sitename + 'Process')
def extractor(sitename):
return getattr(module, sitename + 'Extractor')
Where module
is the current module (or the module that has these functions).
To get this module as an object:
import sys
module = sys.modules[__name__]
Assuming of course, that the generic main function does something like this:
figure out sitename based on input. get the extractor function for the site get processor function for the site call the extractor then the processor