You Are Here:

Community: Developer Discussion Boards

#1 Old Seek of URL in Python? - 2008-10-28, 09:54

Join Date: Feb 2008
Posts: 6
timoriensis
Offline
Registered User
Hi,
I'd like to fetch some part of a big file at a URL, but not all the data always. Thus just downloading everything sounds wasting of resources and user's time.

I thought that I could open it, e.g.,
file_in = urllib2.urlopen(file_input_name)

and then use read & seek:
data_in1 = file_in.read(read_some_bytes)
seek to point2 in file_input_name
data_in2 = file_in.read(read_some_bytes_again)
seek to point3 in file_input_name
etc

but after some trying and crying I found discussion at:
http://mail.python.org
"seek() is not a stream operation. It is a random access operation (file-like != stream).... HTTP resources are in essence streams so they implement read() but not seek()... "

Thus sounds good clarifications. But as you guess, what is then the used way to get seek-functionality working in pyS60?
Should I use other methods to open than urllib2.urlopen?

This might be very basic question but I already spend some time with this and did not find anything related that was really useful. Of course I found a lot of other useful and interesting python stuff
Reply With Quote

#2 Old Re: Seek of URL in Python? - 2008-10-28, 17:27

Join Date: Feb 2008
Posts: 743
Location: Belo Horizonte, Brazil
Send a message via Skype™ to Rafael T.
Rafael T.'s Avatar
Rafael T.
Offline
Forum Nokia Champion
Hi timoriensis,

I didn't got you point in this question. Do you want to search a text in the URL?

If yes, you can do this:

Code:
url = "http://www.forum.nokia.com"

if url.find(u"nokia") == -1:
    
    print "nokia not found on url"

else:
    print "nokia found on url"
So, this will try to find the text "nokia" on the url variable. If it is -1, the text was not found.



Hope I got it,

Rafael.
Reply With Quote

#3 Old Re: Seek of URL in Python? - 2008-10-28, 20:28

Join Date: Sep 2005
Posts: 314
Location: Finland, Helsinki
aaaaapo
Offline
Regular Contributor
Quote:
Originally Posted by timoriensis View Post
Hi,
I'd like to fetch some part of a big file at a URL, but not all the data always.
If your web server supports HTTP byte range, you can ask server to start serving file from any byte you want
(Range: bytes=nnnnnnn- header). These documents explain something about this:

http://www.lassosoft.com/documentati...dex.lasso?9233
http://en.wikipedia.org/wiki/Byte_serving

I am not sure if you can request multiple chunks at one request, but it may be possible.
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump
Similar Threads
Thread Thread Starter Forum Replies Last Post
Please help installing Python libraries on S60 ericroijen Python 11 2009-07-18 11:43
Python for S60.Read it once jalpesh_patel17 Python 0 2008-09-08 06:45
[announce] the first Mobile Python book is now available ! cyke64 Python 1 2008-01-08 10:58
[announce] Mobile Python book soon in Sept 2007 ! cyke64 Python 11 2007-10-03 20:46
Reminder of Python app gallery URL slitchfield Python 0 2006-02-14 09:55

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomE2fforumE2fshowthreadE2ephpE3ftE3d81449X qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE44iscussionQ qdcZtypeQUqfntypeZE44iscussionContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtopicQUqfnTopicZpythonQ qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE44iscussionQ qfnZtypeQUqfntypeZE44iscussionContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qfnZuserE5ftagQSxpythonX qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE44iscussionQ qrdfZtypeQUqfntypeZE44iscussionContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ