爬虫总是返回空值

为什么我的啊
各位大哥帮我看看吧
代码描述:这是一个爬取猫眼电影top100的爬虫
import requests
import re

def get_html(url):
kv = {
‘User-Agent’:’ Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3724.8 Safari/537.36’
}
try:
r = requests.get(url,headers = kv,timeout = 30)
r.raise_for_status()
r.encoding = r.apparent_encoding
return r.text
except:
return “”

def parsehtml(ilt , html):
movielink = re.findall(r’p.?title=(.?)data’,html,re.S)
actorlink = re.findall(r’.?star">(.?)

’,html,re.S)
for i in range(len(movielink)):
movie = eval(movielink[i].split(’:’)[3])
actor = actorlink[i].split(’:’)[-2]
ilt.append([movie , actor])

def printmoviel(ilt):
tplt = “{:4}\t{:8}\t{:16}”
print(tplt.format(“序号”, “电影”, “主演”))
count = 0
for g in ilt:
count = count + 1
print(tplt.format(count, g[0], g[1]))

def main():
start_url = “https://maoyan.com/board/4”
depth = 3
infolist = []
for i in range(depth):
try:
use_url = start_url +"?offset="+str(i*10)
html = get_html(use_url)
parsehtml(infolist , html)
except:
continue
printmoviel(infolist)

你可能感兴趣的:(爬虫总是返回空值)