Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cassandra/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x Python(Pyppeteer):[WinError 10054]远程主机强制关闭了现有连接_Python 3.x_D3.js_Localhost_Puppeteer_Google Chrome Headless - Fatal编程技术网

Python 3.x Python(Pyppeteer):[WinError 10054]远程主机强制关闭了现有连接

Python 3.x Python(Pyppeteer):[WinError 10054]远程主机强制关闭了现有连接,python-3.x,d3.js,localhost,puppeteer,google-chrome-headless,Python 3.x,D3.js,Localhost,Puppeteer,Google Chrome Headless,我试图通过使用Python的本地服务器设置提供一些HTML,然后使用pyppeteer模块拍摄网页的屏幕截图 这是截图的Python代码 pyppeteer导入启动中的 异步def main(): 浏览器=等待启动(headless=真) page=wait browser.newPage() arg=sys.argv[1] 等待页面。转到(“http://localhost:8888/map.html”,{'waitUntil':'networkidle2'}) 等待page.pdf({'pa

我试图通过使用Python的本地服务器设置提供一些HTML,然后使用
pyppeteer
模块拍摄网页的屏幕截图

这是截图的Python代码

pyppeteer导入启动中的

异步def main():
浏览器=等待启动(headless=真)
page=wait browser.newPage()
arg=sys.argv[1]
等待页面。转到(“http://localhost:8888/map.html”,{'waitUntil':'networkidle2'})
等待page.pdf({'path':'screenshot.pdf','scape':True,'format':'A4'});
等待浏览器关闭()
asyncio.get_event_loop()。运行_直到完成(main())
下面是我试图通过Python服务器提供的
map.html
代码。它读入带有一些函数设置的json文件,并调用包含一些D3JavaScript代码的
flex_map


d3.json(“/settings/map_settings.json”)。然后(函数(mapSettings){
flex_地图(mapSettings.geoJsonFile,
mapSettings.dataFile,
mapSettings.fillVariable,
mapSettings.geoVariable,
mapSettings.geoJsonGeoVariable,
mapSettings.legend_标题,
mapSettings.legendTranslateX,
mapSettings.legendtransaley);
});
当我在创建本地服务器后使用python take_screenshot.py提交此代码时,我得到以下错误:

Serving HTTP on 0.0.0.0 port 8888 (http://0.0.0.0:8888/) ...
127.0.0.1 - - [23/Apr/2020 18:34:02] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [23/Apr/2020 18:34:04] "GET /map.html HTTP/1.1" 304 -
127.0.0.1 - - [23/Apr/2020 18:34:04] "GET /settings/map_settings.json HTTP/1.1" 304 -
127.0.0.1 - - [23/Apr/2020 18:34:04] "GET /data/temp_data.csv HTTP/1.1" 304 -
127.0.0.1 - - [23/Apr/2020 18:35:08] "GET /map.html HTTP/1.1" 200 -
127.0.0.1 - - [23/Apr/2020 18:35:08] "GET /js/legend.js HTTP/1.1" 200 -
127.0.0.1 - - [23/Apr/2020 18:35:08] "GET /js/flex_map.js HTTP/1.1" 200 -
127.0.0.1 - - [23/Apr/2020 18:35:08] "GET /settings/map_settings.json HTTP/1.1" 200 -
127.0.0.1 - - [23/Apr/2020 18:35:09] "GET /data/temp_data.csv HTTP/1.1" 200 -
127.0.0.1 - - [23/Apr/2020 18:35:09] "GET /geoJSON/us_counties.json HTTP/1.1" 200 -
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 52861)
Traceback (most recent call last):
  File "C:\Anaconda\lib\socketserver.py", line 650, in process_request_thread
    self.finish_request(request, client_address)
  File "C:\Anaconda\lib\socketserver.py", line 360, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "C:\Anaconda\lib\http\server.py", line 646, in __init__
    super().__init__(*args, **kwargs)
  File "C:\Anaconda\lib\socketserver.py", line 720, in __init__
    self.handle()
  File "C:\Anaconda\lib\http\server.py", line 426, in handle
    self.handle_one_request()
  File "C:\Anaconda\lib\http\server.py", line 394, in handle_one_request
    self.raw_requestline = self.rfile.readline(65537)
  File "C:\Anaconda\lib\socket.py", line 589, in readinto
    return self._sock.recv_into(b)
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host
----------------------------------------
我不确定这个问题的根源在哪里。一件奇怪的事情是,如果我将HTML文件更改为


flex_地图(参数转到此处…);
代码运行良好,并截图,因此可能与加载json文件有关,但我不确定如何解决这个问题。通过本地主机在Chrome上打开
map.html
代码也可以