View Single Post
Old May 22nd, 2006, 9:46 AM   #98
Arevos
Programming Guru
 
Arevos's Avatar
 
Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5 Arevos is on a distinguished road
Quote:
Originally Posted by zem52887
lastly, I'm trying to test my get_company_urls to see if I'm ready for get_company_data, and I'm encountering some errors while trying to run the module, if anyone could help me troubleshoot I'd really appreciate it because I've been staring at this code for awhile and can't figure out what I did wrong.
What do the error messages say? If you don't give people the error messages that were displayed, it makes it very much more difficult to solve the problem.

Also, when you're testing, test each function individually and in isolation. This takes less time than testing all the functions together, and doesn't hammer Yahoo! so hard.

However, I believe your problem lies in this piece of code:
for industry_url in get_industry_urls(industry_page):
    	company_index = get_company_index(industry_url)
  
        for company_index in get_company_index(industry_url):
            print get_company_urls(company_index)
You have a loop that you don't need. Remember that get_company_index returns a single value. This is because each industry page only has one company index each.

For-loops, like list comprehensions, are used for lists and sequences of values only. They are a way of apply code to each item in a list. Attempting to apply a for-loop to a single item only causes errors.

Remove the unnecessary for-loop and add in a sleep function, so that your program waits for a certain amount of time between each industry. This is to ensure you don't overload the Yahoo! servers. If you query Yahoo! too fast, too often, then Yahoo! may consider you a malicious entity and prevent your IP address from accessing the site. Therefore, be careful and be polite.
Arevos is offline   Reply With Quote