Wow, what a fantastic analogy, and a life lesson too
so now that I have tested each of the functions under:
def get_company_data(company_url):
soup = BeautifulSoup(urlopen(company_url))
#Company Profile
profile = soup.fetchText(re.compile("Company Profile"))[2]
companyprofile = profile.findNext("table")
#Contact Information
contact = soup.firstText(re.compile("Contact Information"))
contacttable = contact.findParent("table")
#Financial Highlights
highlights = soup.firstText(re.compile("Highlights"))
fhighlights = highlights.findParent("table")
z = len(highlights)
if z == 0:
print "N/A"
else:
print fhighlights
#Key People
key = soup.firstText(re.compile("Key People"))
keypeople = key.findParent("table")
and see that they work, I need to add in a return statement. Is this return statement under the def_get_company_names, or is it after the for loops at the end of the script?
also, should it look something like:
return[company_profile, contacttable, fhighlights, keypeople]
Okay I'm excited that this is all coming together but I don't really know where to go from here. I'm not ready to import into a CSV yet, am I? I don't know how to combine each of the functions with the for-loops etc., and I could use some help formatting the return statement for def_get_company_data. Thanks for everyone who's helped thus far.