views:

26

answers:

3
from google.appengine.ext import webapp
from google.appengine.ext.webapp import util
from google.appengine.ext import db
from google.appengine.api import urlfetch

class TrakHtml(db.Model):
  hawb = db.StringProperty(required=False)
  htmlData = db.TextProperty()

class MainHandler(webapp.RequestHandler):
  def get(self):
    Traks = list()
    Traks.append('93332134')
    #Traks.append('91779831')
    #Traks.append('92782244')
    #Traks.append('38476214')

    for st in Traks :
      trak = TrakHtml()
      trak.hawb = st
      url = 'http://etracking.cevalogistics.com/eTrackResultsMulti.aspx?sv='+st

      result = urlfetch.fetch(url)
      self.response.out.write(result.read())

      trak.htmlData = result.read()
      trak.put()

result.read() is not giving whole file , it giving some portion. trak.htmlData is a TextProperty() so it has to store whole file and i want that only.

A: 

you call result.read() twice. That's probably why it's fragmented.

SilentGhost
A: 

This link has info on the return value of urlfetch.fetch(url)

http://code.google.com/appengine/docs/python/urlfetch/responseobjects.html

It looks like you want to do result.content.read()

jjfine
A: 

I note that you are calling read() twice, which may be the problem.

When I look at the specs for urlfetch.fetch(), it returns a response object.

The contents are directly accessible as result.contents, so you shouldn't need to call the (undefined??) read function.

Oddthinking