用python实现的抓取腾讯视频所有电影的爬虫
# -*- coding: utf-8 -*-
import re
import urllib2
from bs4 import BeautifulSoup
import string, time
import pymongo
NUM = 0 #全局变量,电影数量
m_type = u'' #全局变量,电影类型
m_site = u'qq' #全局变量,电影网站
#根据指定的URL获取网页内容
def gethtml(url):
req = urllib2.Request(url)
response = urllib2.urlopen(req)
html = response.read()
return html
'''
在学习过程中有什么不懂得可以加我的python学习交流扣扣qun,934109170,群里有不错的学习教程与开发工具。
'''
#从电影分类列表页面获取电影分类
def gettags(html):
global m_type
soup = BeautifulSoup(html) #过滤出分类内容
#print soup
#<ul class="clearfix _group" gname="mi_type" gtype="1">
tags_all = soup.find_all('ul', {'class' : 'clearfix _