python爬虫问题:这个IndexError到底错在哪里
>>>#coding=utf-8...importrequests>>>importre>>>#1、下载一个网页...url='http://www.jingcaiyue...
>>> # coding=utf-8... import requests>>> import re>>> # 1、下载一个网页... url = 'http://www.jingcaiyuedu.com/book/368416.html'>>> # 2、模拟浏览器发送http请求... response = requests.get(url) # type: object>>> # 3、编码方式... response.encoding = 'utf-8'>>> # 4、得到源文件... html = response.text>>> # 小说名字... title = re.findall(r'<meta property="og:title" content=".*?"/>', html)[0]Traceback (most recent call last): File "<stdin>", line 2, in <module>IndexError: list index out of range>>> print(title)Traceback (most recent call last): File "<stdin>", line 1, in <module>NameError: name 'title' is not defined>>>
展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询