python2.7 urllib2 obtains incomplete display of web pages
習慣沉默
習慣沉默 2017-05-18 11:01:12
0
1
929

I used the urllib2 module in python2.7 to write a very simple code to obtain the source code of the web page, but the source code of the returned web page only has the lower half, such as </html></body> and other concluding words. , but there is no code in the upper part such as <!doctype><html>. I hope someone can help me. Thank you. The code is as follows:

coding:utf-8

import urllib2
resp = urllib2.urlopen("http://www.baidu.com")
print resp.read()
Get the web page as follows (beginning and end):

習慣沉默
習慣沉默

reply all(1)
曾经蜡笔没有小新

The code is fine, the problem is the command window. resp.read() obtains all the content, but the command window is not fully displayed.
python test.py > res.txt Output to file for viewing

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template