我正在使用GAE pyhton 2.5和Beautiful Soup 3.08,并且正在发生一些事情,它会切断我文本的第一部分。
这是我的代码:
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:
i.string
else:
print "Couldn't find TRs in Soup!"
运行此代码的我的应用网站是:http://mwp-test2.appspot.com/ 发生的事情是第一次打印根本没有发生。有任何想法吗? (我也很难用美味汤找到所有,但我一直在计划一旦我弄清楚这个截断的问题)
答案 0 :(得分:0)
当我运行您的页面时,第一次打印似乎确实有效。此外,您应该使用response.out.write而不是print。在这里查看文档:{{3}}