![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#11 |
|
Programming Guru
![]() Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 4
![]() |
Could you explain what it is your function is trying to do? There may be an easier way of doing it.
|
|
|
|
|
|
#12 |
|
Newbie
Join Date: Oct 2006
Posts: 23
Rep Power: 0
![]() |
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!
|
|
|
|
|
|
#13 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
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 |
|
|
|
|
|
#14 | ||
|
Newbie
Join Date: Oct 2006
Posts: 23
Rep Power: 0
![]() |
Quote:
Quote:
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! |
||
|
|
|
|
|
#15 |
|
Programming Guru
![]() Join Date: Apr 2005
Posts: 1,799
Rep Power: 5
![]() |
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? |
|
|
|
|
|
#16 |
|
Newbie
Join Date: Oct 2006
Posts: 23
Rep Power: 0
![]() |
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! |
|
|
|
|
|
#17 |
|
Programming Guru
![]() Join Date: Apr 2005
Posts: 1,799
Rep Power: 5
![]() |
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. |
|
|
|
|
|
#18 |
|
Newbie
Join Date: Oct 2006
Posts: 23
Rep Power: 0
![]() |
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! |
|
|
|
|
|
#19 |
|
Programming Guru
![]() Join Date: Apr 2005
Posts: 1,799
Rep Power: 5
![]() |
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. |
|
|
|
|
|
#20 |
|
Newbie
Join Date: Oct 2006
Posts: 23
Rep Power: 0
![]() |
thanks for your help
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
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 |