我在generalpythonpath中安装了一个beautifulSoup,在virtualenv中安装了另一个
beautifulsoup4 - 4.1.3 - active # in general Python installation
以及
^{pr2}$我在这两个环境中运行以下代码
^{3}$在一般的Python安装中,它给了我
>>> soup.select('.article-text .body')
[<p class="body"> It is that time when aviation buffs get ready to take off to the Air Force Station in Yelahanka here when the ninth edition of Aero India will be inaugurated by Defence Minister A.K. Antony on February 6.</p>, <p class="body">They can watch aerobatics by, among others, the Flying Bulls from the Czech Republic and Russian Knights — the Russian Air Force Aerobatic Team will complement Indian Air Force’s Sarang Aerobatic Team — at the biennial event that provides a platform for Indian and foreign vendors.</p>, <p class="body">However, IAF’s pride — the Surya Kiran Aerobatic Tea — which has performed to huge plaudits from the audience in the previous shows, will not be there for the country’s premier air show, a press release said.</p>, <p class="body">All exhibition space has been sold out and this edition is expected to see the participation of over 600 companies and 768 overseas delegations. </p>, <p class="body">The largest overseas participation is from the U.S. followed by Israel and Russia. The other major participants include France, the U.K., Germany and Belgium, Bulgaria, Italy, Ukraine, Australia, Belarus, Czech Republic, Japan, Norway, South Africa, Spain, Switzerland, Austria, Brazil, Canada, The Netherlands, Romania, Sweden, Singapore and the UAE.</p>, <p class="body">Organised by the Department of Defence Production, the five-day show aims at promoting products and services being offered by the Indian Defence industry in the international market.</p>]
>>>
而在virtualenv环境中,它什么也不显示
>>> soup.select('.article-text .body')
[]
是什么引起了这个问题?如何在虚拟环境中修复它?在
这个问题最常见的原因是one environment has a parser library installed which the other lacks。检查一下。在
我也面临同样的问题。对我有效的解决方案是显式地指示解析器。就我而言,这是:
soup = BeautifulSoup(markup, "html5lib")
相关问题 更多 >
编程相关推荐