python 抓取豆瓣电影

#coding=utf-8

import urllib2
from bs4 import BeautifulSoup
import string

page = urllib2.urlopen('https://movie.douban.com/chart');
html = page.read()

soup = BeautifulSoup(html,"html.parser",from_encoding="utf-8")
links = soup.find_all('a')

print "获取全部连接"
for link in links:
    if string.find(link['href'],'movie.douban.com/subject')!=-1:
        print link['href'],link.get_text()

你可能感兴趣的:(python 抓取豆瓣电影)