Take the 2-minute tour ×

I'm using GAE pyhton 2.5 with Beautiful Soup 3.08 and something is happening that cuts off the first portion of my text.

Here is my code:

from google.appengine.api import urlfetch
from BeautifulSoup import BeautifulSoup

url = 'http://www.cmegroup.com/CmeWS/mvc/xsltTransformer.do?xlstDoc=/XSLT/da/DailySettlement_CPC-FUT.xsl&url=/da/DailySettlement/V1/DSReport/ProductCode/J4/FOI/FUT/EXCHANGE/XNYM/Underlying/J4?tradeDate=08/16/2012'

print '<hr>This is the raw result fetched (print result.content)<hr>'
result = urlfetch.fetch(url = url, method = urlfetch.GET)
print result.content

soup = BeautifulSoup(result.content)
print '<hr>This is prettified soup (soup.prettify)<hr>'
print soup.prettify()

print '<hr>here is the print out of iteration through the findall<hr>Go!<br>'
trSet = soup.findAll('tr')
if trSet is not None:
  for i in trSet:
  print "Couldn't find TRs in Soup!"

My app site running this code is: http://mwp-test2.appspot.com/ What is happening is the first print is not occurring at all. Any ideas? (also I'm having trouble with Beautiful soup's findAll, but I was planning on asking that once I figure out this truncating problem)

share|improve this question

1 Answer 1

up vote 0 down vote accepted

When I ran your page the first print did appear to be working. Also, you should be using response.out.write instead of print. Take a look at the docs here: https://developers.google.com/appengine/docs/python/tools/webapp/overview

share|improve this answer
I had previously read through the whole "Getting Started" section, but had started stripping out pieces to debug. Looks like I got too stripped down, using the WSGI set up in your link did the trick! Thanks sir –  Mike PG Aug 20 '12 at 1:45

Your Answer


