![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Oct 2006
Posts: 23
Rep Power: 0
![]() |
def find_all_items(site):
site = urllib.urlopen(site).read()
all_items = re.findall(r'watch\.asp\?\w+\=\w*\&\w*\=\w+',site)
next_page = re.findall(r'Watches\.asp\?\w+\=[0-9]+\&pg\=\w+',site)
try:
find_all_items(urllib.basejoin("<some url>",next_page[0]))
except IndexError:
pass
return remove_dups(all_items) # ,<---- this removes all the duplicate itemsHow do i keep the value of all_items that i have within the first function call and return a list of all the items at once also from the second function call Now the list is being overwritten |
|
|
|
|
|
#2 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
Is this a tutorial or a question? It doesn't seem to say, anywhere.
__________________
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 |
|
|
|
|
|
#3 |
|
Expert Programmer
|
It never fails to amaze me how so many of the newcomers to this forum have such unbelievably bad (written) communication skills.
|
|
|
|
|
|
#4 |
|
Programming Guru
![]() Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5
![]() |
def find_all_items(site):
site = urllib.urlopen(site).read()
all_items = re.findall(r'watch\.asp\?\w+\=\w*\&\w*\=\w+',site)
next_page = re.findall(r'Watches\.asp\?\w+\=[0-9]+\&pg\=\w+',site)
try:
all_items.extend(find_all_items(urllib.basejoin("<some url>",next_page[0])))
except IndexError:
pass
return remove_dups(all_items) # ,<---- this removes all the duplicate itemsPerhaps: def find_all_items(site):
site = urllib.urlopen(site).read()
all_items = set(re.findall(r'watch\.asp\?\w+\=\w*\&\w*\=\w+',site))
next_page = re.findall(r'Watches\.asp\?\w+\=[0-9]+\&pg\=\w+',site)
try:
all_items.union(find_all_items(urllib.basejoin("<some url>",next_page[0])))
except IndexError:
pass
return all_items |
|
|
|
|
|
#5 |
|
Newbie
Join Date: Oct 2006
Posts: 23
Rep Power: 0
![]() |
I tried both the examples the issue is that the list all_items is cleared when the function is called again!
|
|
|
|
|
|
#6 |
|
Programming Guru
![]() Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5
![]() |
Hm. It might help if you showed all your code, as it's difficult to understand exactly what you're asking for. Do you want some sort of persistence? Then you either need a functor:
python Syntax (Toggle Plain Text)
python Syntax (Toggle Plain Text)
python Syntax (Toggle Plain Text)
python Syntax (Toggle Plain Text)
|
|
|
|
![]() |
| 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 |
| dev c++ software, template problem | cairo | C++ | 11 | Jun 2nd, 2006 12:42 PM |
| libraries | matko | C | 1 | Jan 22nd, 2006 2:12 PM |
| Jackpot game | zorin | Visual Basic | 3 | Jun 10th, 2005 1:19 PM |
| User-defined creatNode and deleteNode functions for a doubly-linked list | jgs | C | 2 | Apr 28th, 2005 8:53 AM |
| airport Log program using 3D linked List : problem reading from file | gemini_shooter | C++ | 0 | Mar 2nd, 2005 4:12 PM |