Home  >  Article  >  Backend Development  >  Python crawler crawls all movies of Tencent Video (code)

Python crawler crawls all movies of Tencent Video (code)

不言
不言forward
2018-10-12 15:12:588458browse

The content this article brings to you is about the python crawler crawling all the movies (code) of Tencent Video. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.

Using python to crawl all movies of Tencent Video

# -*- 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

#从电影分类列表页面获取电影分类

def gettags(html):

    global m_type

    soup = BeautifulSoup(html)      #过滤出分类内容

    #print soup

    #

The above is the detailed content of Python crawler crawls all movies of Tencent Video (code). For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:cnblogs.com. If there is any infringement, please contact admin@php.cn delete