Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old May 19th, 2006, 5:39 PM   #81
zem52887
Hobbyist Programmer
 
Join Date: May 2006
Posts: 127
Rep Power: 3 zem52887 is on a distinguished road
yeah I figured that it had something to do with the server moreso than the code, because it's running well again... I can't explain how much I appreciate your help

out of curiousity? DDOSing?
zem52887 is offline   Reply With Quote
Old May 19th, 2006, 5:42 PM   #82
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
this is absolutely amazing, it's listing out every single company index page... it's taking awhile but i can't complain. whoa wait it just turned red on me and I got a bunch of errors
That's Yahoo! closing your connection down because you're going too fast - see my post about the sleep function

Quote:
Originally Posted by zem52887
don't know why that's happening
Ah, that's a problem with my code. As well as the industry links, it's also found the "Alphabetical" link!
def get_industry_urls(industry_page):
	soup  = BeautifulSoup(urlopen(industry_page))
	links = soup.fetch("table")[7].fetch("a")
	return [a['href'] for a in links if a.string != "Alphabetical"]
The above bit of code has an if-statement embedded in the list comprehension. Load up the Python tutorial to learn more about if-statements.
Arevos is offline   Reply With Quote
Old May 19th, 2006, 5:47 PM   #83
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
yeah I figured that it had something to do with the server moreso than the code, because it's running well again... I can't explain how much I appreciate your help

out of curiousity? DDOSing?
Websites only have so much bandwidth. If lots of people downloaded ten pages every second, then Yahoo! would become laggy and unresponsive, so Yahoo!'s servers block people who are downloading too much, too fast.

It's also common courtesy not to stress other people's servers. Put in a sleep(1) in the loop and you'll be being a lot more polite.

Malicious computer users deliberately try to take too much bandwidth from other servers. This can cause servers to go down under the strain, which means the company will lose business. This is called a Denial of Service attack, or a DOS attack. When a denial of service attack comes from many different computers, it's called a distributed denial of service attack, or a DDOS attack.

Also, look up try/except blocks in the Python tutorial. That information will come in handy later.
Arevos is offline   Reply With Quote
Old May 19th, 2006, 5:50 PM   #84
zem52887
Hobbyist Programmer
 
Join Date: May 2006
Posts: 127
Rep Power: 3 zem52887 is on a distinguished road
okay, I have to look that up but for now I'm going to cheat and just use it. I'll take a look at it a little later tonight, but since you're 6 hours ahead (UK right?), I want to get my final question in for the night...

now I need a get_company_urls function, from there I need a get_company_data and I'm basically done correct?

okay I'm an intern and I'm the last one left in the office, I think it's time to depart. Thanks for the help Arevos. Have a good weekend.
zem52887 is offline   Reply With Quote
Old May 19th, 2006, 5:58 PM   #85
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
now I need a get_company_urls function, from there I need a get_company_data and I'm basically done correct?
Yep, that's about it. Remember to use sleep so that you don't stress the server.

Also, some error handling will probably be necessary. Ideally, you don't want your program to end the moment your connection times out once. Fortunately, error handling is easier than it sounds

Quote:
Originally Posted by zem52887
okay I'm an intern and I'm the last one left in the office, I think it's time to depart. Thanks for the help Arevos. Have a good weekend.
You too!
Arevos is offline   Reply With Quote
Old May 19th, 2006, 7:06 PM   #86
The Dark
Expert Programmer
 
Join Date: Jun 2005
Posts: 874
Rep Power: 4 The Dark is on a distinguished road
Great job Arevos! This is some excellent tutoring.
Excellent work zem52887, you learn quick and are actually reading every reply! I hope you get a job out of this (or at least avoid carpal tunnel).

There should be a hall of fame for threads like these.
The Dark is offline   Reply With Quote
Old May 19th, 2006, 7:22 PM   #87
Dameon
Troll
 
Dameon's Avatar
 
Join Date: Apr 2005
Location: Texas
Posts: 732
Rep Power: 4 Dameon is on a distinguished road
Is it just me, or does ripping off data from Yahoo Finance not seem like how financial institutions are supposed to operate?
__________________
MD5(sig) = bcef75433db02e9ad9bf81d6f7c5c270
Dameon is offline   Reply With Quote
Old May 19th, 2006, 7:24 PM   #88
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Absolutely. I was going to call attention to this, as well as the assembler thread involving Narue, as prime examples of the true worth of a forum. Two noobs coupled with two top-notch pros; anyone not following them has missed a true pleasure.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old May 19th, 2006, 7:36 PM   #89
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
I've been very impressed myself. It's nice to see people who take in information, are polite, and try stuff themselves before asking questions. It's a reminder of why I'm here.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old May 20th, 2006, 3:57 AM   #90
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 Dameon
Is it just me, or does ripping off data from Yahoo Finance not seem like how financial institutions are supposed to operate?
Well, I seem to recall that that databases that contain only facts aren't protected by copyright law, which is sensible enough. Some large sports-related organisations have managed to subvert this, but in general you can't copyright facts, which is what Yahoo! appears to offer.

Capitalism being what it is, companies will always seek the easiest option that's not outright illegal, so wanting to gather public-domain financial information from a website doesn't come as a surprise to me.
Arevos is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 9:08 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC