Crossin的编程教室

标题: 这是为啥 [打印本页]

作者: 东东哥    时间: 2018-12-24 23:48
标题: 这是为啥
  1. #!usr/bin/python
  2. # coding=UTF-8
  3. import urllib2
  4. from bs4 import BeautifulSoup
  5. print '豆瓣正在热映:'
  6. url="http://movie.douban.com"
  7. html=urllib2.urlopen(url).read()
  8. soup=BeautifulSoup(html)
  9. div_hot=soup.find('div',{"id":"sceeening"})
  10. for i in div_hot.find_all('li',class_='title'):
  11.     movie_title=i.a.get_text()
  12. #movie_title = movie_title.strip() #去除movie_title两边的空格
  13.     print movie_title

  14. print '\n豆瓣近期热门:'
  15. div_new=soup.find('div',{"id":"new-movies"})
  16. for i in div_new.find_all('li',class_='title'):
  17.     movie_new=i.a.get_text
  18.     print movie_new

复制代码
File "D:\Python\python27\lib\site-packages\beautifulsoup4-4.6.3-py2.7.egg\bs4\dammit.py", line 14, in <module>
    from html.entities import codepoint2name
ImportError: No module named html.entities


作者: crossin先生    时间: 2018-12-25 17:35
试下装个库 pip install future

或者改用 python3




欢迎光临 Crossin的编程教室 (https://bbs.crossincode.com/) Powered by Discuz! X2.5