刚开始学,看不懂错在哪里,求指教。
# coding:utf-8 import requests import re import sys headers = {'User-Agent':'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36'} html = requests.get('https://www.qidian.com/rank',headers = headers) # print(html.text) main_title = re.findall('<ul>(.*?)</ul>',html,re.S) title = re.findall('">(.*?)</a>',main_title,re.S) for each in title: print(each)Traceback (most recent call last):
File "E:/python/spider_test/needspider.py", line 9, in <module>
main_title = re.findall('<ul>(.*?)</ul>',html,re.S)
File "C:\Users\34429\AppData\Local\Programs\Python\Python36\lib\re.py", line 222, in findall
return _compile(pattern, flags).findall(string)
TypeError: expected string or bytes-like object