谁能告诉我出了什么错?
代码如下:
from tornado.httpclient import AsyncHTTPClient
import os
from tornado.ioloop import IOLoop
# 异步客户端
def parse(content):
import bs4
bs = bs4.BeautifulSoup(content,'html.parser')
h4list = [h4.text for h4 in bs.select('ul.foot_nav.main h4')]
for h in h4list:
print(h)
def handle_response(response):
body = response.body
file = os.path.join(os.getcwd(),'templates','index.html')
with open(file,'wb') as fw:
fw.write(body)
parse(body)
def load1(url,callback):
http_client = AsyncHTTPClient()
http_client.fetch(url,callback=callback)
load1(url='http://www.bjsxt.com',callback=handle_response)
IOLoop.instance().start()
报以下错误:
Traceback (most recent call last):
File "E:/软件下载/Python/untitled/2020.8.13/tornado/test2/test2.py", line 32, in <module>
load1(url='http://www.bjsxt.com',callback=handle_response)
File "E:/软件下载/Python/untitled/2020.8.13/tornado/test2/test2.py", line 29, in load1
http_client.fetch(url,callback=callback)
File "C:\Users\lenovo\AppData\Local\Programs\Python\Python37\lib\site-packages\tornado\httpclient.py", line 284, in fetch
request = HTTPRequest(url=request, **kwargs)
TypeError: __init__() got an unexpected keyword argument 'callback'