Web抓取Python Shell没有响应

Web抓取Python Shell没有响应,python,python-3.x,beautifulsoup,Python,Python 3.x,Beautifulsoup,我正在尝试运行这段基本代码,但即使等待了很长时间,Python shell也会被卡住,我总是发现自己面临“Python 3.6.5 shell(无响应)”。请建议 import requests from bs4 import BeautifulSoup webdump = requests.get("https://www.flipkart.com/").text soup = BeautifulSoup(webdump,'lxml') print(soup.prettify()) 这个页面

我正在尝试运行这段基本代码,但即使等待了很长时间,Python shell也会被卡住,我总是发现自己面临“Python 3.6.5 shell(无响应)”。请建议

import requests
from bs4 import BeautifulSoup
webdump = requests.get("https://www.flipkart.com/").text
soup = BeautifulSoup(webdump,'lxml')
print(soup.prettify())

这个页面大约1MB,因此一次向终端吐出超过974047字节(
soup.prettify()
添加更多的空格和换行符)可能是它卡住的原因

请尝试逐行打印此文本:

for line in soup.prettify().splitlines(False):
    print(line)