View Single Post
Old May 19th, 2006, 5:37 PM   #79
Arevos
Programming Guru
 
Arevos's Avatar
 
Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5 Arevos is on a distinguished road
Debugging is the skill of getting your programs to work. One way to debug a piece of code is to go through it and work out what it's doing.
industry_url = "get_industry_urls(industry_page)"
This sets the industry_url to hold a piece of text (or a string). Strings are denoted by quotation marks. I'll hazard a guess and say that this isn't what you want to do.

for industry_url in get_industry_urls(industry_page):
    	company_index = get_company_index(industry_url)
This piece of code goes through each of the industries in turn, and for each industry, it puts the company index into a variable called "company_index", overwriting the previous value.
print get_company_index(industry_url)
This code uses the last industry_url value and gets the company index of that.

Since hammering Yahoo! with some more iterative searches probably isn't a good idea, I'll show you the answer:
for industry_url in get_industry_urls(industry_page):
	print get_company_index(industry_url)
However, you have to understand the answer, otherwise it's of no use, so explain why it works

Also, Yahoo! seems to have a filter of some kind to stop people from DDOSing it's site. Thus, we need to put in a delay between fetching each site. The sleep function does this well. Sleep(1) will wait for 1 second, sleep(2) will wait for 2 and so forth:
from time import sleep

for industry_url in get_industry_urls(industry_page):
	print get_company_index(industry_url)
	sleep(1)
Again, explain what this does.
Arevos is offline   Reply With Quote