Programming Forums
User Name Password Register
 

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

Reply
 
Thread Tools Display Modes
Old Oct 16th, 2006, 5:23 PM   #11
Arevos
Programming Guru
 
Arevos's Avatar
 
Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 4 Arevos is on a distinguished road
Could you explain what it is your function is trying to do? There may be an easier way of doing it.
Arevos is offline   Reply With Quote
Old Oct 16th, 2006, 5:36 PM   #12
nytrokiss
Newbie
 
Join Date: Oct 2006
Posts: 23
Rep Power: 0 nytrokiss is on a distinguished road
sure i want it to download a webpage grab all the product url's on a page if there is a second page i want it to go to the second page and grab them there also and then return a list of url's and my issue is that it won't return when i want it to!
nytrokiss is offline   Reply With Quote
Old Oct 16th, 2006, 5:44 PM   #13
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
You're not paying attention to your responses, or, at least, not incorporating the suggestions. The exclamation points suggest, perhaps, a degree of frustration. Relax and re-read your responses, which are cogent.
__________________
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 Oct 16th, 2006, 5:54 PM   #14
nytrokiss
Newbie
 
Join Date: Oct 2006
Posts: 23
Rep Power: 0 nytrokiss is on a distinguished road
Quote:
Originally Posted by DaWei View Post
You're not paying attention to your responses, or, at least, not incorporating the suggestions. The exclamation points suggest, perhaps, a degree of frustration. Relax and re-read your responses, which are cogent.
Please explain me what i should of done then i have looked at what i have written and what was written for me and i seem to still have a problem! And par my last post i have answered correctly!

Quote:
Originally Posted by nytrokiss View Post
sure i want it to download a webpage grab all the product url's on a page if there is a second page i want it to go to the second page and grab them there also and then return a list of url's and my issue is that it won't return when i want it to!

I am not trying to drive anyone nuts but this issue has been doing that to me so i am sorry if i have done anything to anyone!
nytrokiss is offline   Reply With Quote
Old Oct 16th, 2006, 6:02 PM   #15
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Posts: 1,799
Rep Power: 5 Sane will become famous soon enough
Well I'd start with breaking your program up in to more logical chunks. The large blocks, and nested operations, suggest that this could be dealt with more efficiently (and cleanly, at that).

I'd start with completing the following function prototypes:
def grab_page(url):
    """Return the page of the requested URL."""

def find_links(page):
    """Return a list of all the links in the given page."""

def find_items(url):
    """Using grab_page and find_links, return all of the urls on a given page."""

Writing these individual functions may solve your issue of having to manage several loops at a time (as, clearly you've yet to understand the difference between break/return).

Also, why does your function call itself? You described your function as returning all of the links within a given page. If it keeps on recursively executing, theoretically, it will never end. Or am I missing something?
Sane is offline   Reply With Quote
Old Oct 16th, 2006, 6:15 PM   #16
nytrokiss
Newbie
 
Join Date: Oct 2006
Posts: 23
Rep Power: 0 nytrokiss is on a distinguished road
1. This function is one out of 3 the first grabs the main page the second grabs the links on it and this one is supposed to go to the url supplied by the second function and grab all the links on it now if there is a "next" page that means there is two sub pages so i want it to call itself to grab the links for the next page the code that is calling these functions is
page =scan_page(<some url>')
links = look_for_links(page)
items = find_items(links[0])
print items

P.S Break breaks out of the loop and return returns a value from a function!
nytrokiss is offline   Reply With Quote
Old Oct 16th, 2006, 6:24 PM   #17
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Posts: 1,799
Rep Power: 5 Sane will become famous soon enough
Oh, I see. So it's also dependant on the value of the hyperlink. That provides another reason to split up your program in to even more functions. I'd suggest that you do that, then once you run in to a problem, post all of your code and someone could try to help fix it. As it is currently, your code is very difficult to manage and understand what's happening. I doubt anyone will be kind enough to modify it so it meets its purpose.

I strongly suggest you remove the link in your signature, as I suppose the page is financially beneficial to you. It's okay to have it set to your home page (as you do), but spamming directly (or indirectly) is strictly against the forum's policies.
Sane is offline   Reply With Quote
Old Oct 16th, 2006, 6:30 PM   #18
nytrokiss
Newbie
 
Join Date: Oct 2006
Posts: 23
Rep Power: 0 nytrokiss is on a distinguished road
Ok sorry and i am getting no money for this program i am writing it to learn how to program in python! will it help if i send you the full program in an email! or scrren shots of the issue! (i like my program the way it is and to change it will mean that i have to redesign it )

Thanks for all the help!
nytrokiss is offline   Reply With Quote
Old Oct 16th, 2006, 6:36 PM   #19
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Posts: 1,799
Rep Power: 5 Sane will become famous soon enough
Well, I wasn't saying your program was for money. I don't care about that. I was talking about the link in your signature. It's okay now that you've removed it.

If you don't want to change the design, I understand, but I have already forewarned you that it might be harder to get working. Unless, of course, there's something reasonably simple that's wrong with your code.

However, as Arevos' post suggests, there may be deeper issues with your code that could only be resolved with a rewrite. There are definitely better ways to do most of the things you are doing. Choosing these better ways will not only make things easier for you, but acquire more readable and managable code.

As it pertains to your lack of resolving the suggested problems at hand by both Arevos and I, I feel like I've helped as much I can.
Sane is offline   Reply With Quote
Old Oct 16th, 2006, 6:37 PM   #20
nytrokiss
Newbie
 
Join Date: Oct 2006
Posts: 23
Rep Power: 0 nytrokiss is on a distinguished road
thanks for your help
nytrokiss 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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Combining languages titaniumdecoy Other Programming Languages 12 Jul 13th, 2006 2:03 PM
libraries matko C 1 Jan 22nd, 2006 2:12 PM
Php Postgresql Class Pizentios Show Off Your Open Source Projects 15 Jun 28th, 2005 9:55 AM
Jackpot game zorin Visual Basic 3 Jun 10th, 2005 1:19 PM
airport Log program using 3D linked List : problem reading from file gemini_shooter C++ 0 Mar 2nd, 2005 4:12 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 5:11 PM.

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