I'm still learning python and would like to know what's a good way of
organizing code.
I am writing some scripts to scrape a number of different website that
hold similar information and then collating it all together. Obviously
each site needs to be handled differently, but once the information is
collected then more generic functions can be used.
Is it best to have it all in one script or split it into per site
scripts that can then be called by a manager script? If everything is
in one script would you have per site functions to extract the data or
generic function that contain vary slightly depending on the site, for
example
import firstSiteScript
import secondSiteScrip t
firstsitedata = firstSiteScript .getData('searc h_str)
secondsitedata = secondSiteScrip t.getData('sear ch_str)
etc etc
OR
def getFirstSiteDat a(search_str):
etc etc
def getSecondSiteDa ta(search_str):
etc etc
OR
def getdata(search_ str, website):
if website == 'firstsite':
....
elif website =='secondsite':
etc
organizing code.
I am writing some scripts to scrape a number of different website that
hold similar information and then collating it all together. Obviously
each site needs to be handled differently, but once the information is
collected then more generic functions can be used.
Is it best to have it all in one script or split it into per site
scripts that can then be called by a manager script? If everything is
in one script would you have per site functions to extract the data or
generic function that contain vary slightly depending on the site, for
example
import firstSiteScript
import secondSiteScrip t
firstsitedata = firstSiteScript .getData('searc h_str)
secondsitedata = secondSiteScrip t.getData('sear ch_str)
etc etc
OR
def getFirstSiteDat a(search_str):
etc etc
def getSecondSiteDa ta(search_str):
etc etc
OR
def getdata(search_ str, website):
if website == 'firstsite':
....
elif website =='secondsite':
etc
Comment