[python-win32] RE Explained With screenshot

Bob Gailer bgailer at alum.rpi.edu
Tue Nov 21 00:19:16 CET 2006


James Matthews wrote:
> This is the code i am dealing with..
> Code:
> def next_page_finder(site):
>     site = urlopen(site).read()
>     next_site_pages = []
>     next_site_pages.extend(findall(r'\?Brand=\d+\&pg=\d+',site))
>     new_pages = []
>     for _ in next_site_pages:
>         new_pages.append(basejoin("http://www.goldwatches.com/watches.asp",_))
>     return new_pages
>
> The issue is that when i run the RE
> Code:
> next_site_pages.extend(findall(r'\?Brand=\d+\&pg=\d+',site))
> it returns me an empty list however in the interactive input i run
> something akin to it
>
> Code:
>   
>>>> from re import findall
>>>> from urllib import basejoin,urlopen
>>>> site = urlopen("http://www.goldwatches.com/watches.asp?Brand=11").read()
>>>> findall(r'\?Brand=\d+\&pg=\d+',site)
>>>>         
> Now as you see in the screen shot the interactive interpreter returns
> me a list of values however when i run it in regular python i get an
> empty list why??
>
>
> Screen Shot: http://static.flickr.com/109/301613265_484a49929d_o.jpg
>   
Thank you for the clarification. Running under my IDE (PythonWIn) I get 
the desired results in debug mode and in the interactive window. So I 
can't help. Must be something in the IDE?

-- 
Bob Gailer
510-978-4454



More information about the Python-win32 mailing list