File tree Expand file tree Collapse file tree 1 file changed +8
-7
lines changed
Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -74,13 +74,14 @@ async def run(self):
7474 async def generate (self , url : str , selector : str ) -> None :
7575 while True :
7676 with suppress (Exception ):
77- session = aiohttp .ClientSession ()
78- request = await session .post (choice (url ), data = {"gen" : "" }, timeout = self .config ["request-timeout" ] or 5 )
79- await session .close ()
80- outUrl = \
81- findall ("http://.*" , str (BeautifulSoup (await request .text (), "html.parser" ).select (selector )))[0 ]
82- await aprint (await self .make_beautiful (outUrl ))
83- self .output .write ("%s\n " % outUrl )
77+ with open (self .config ["output" ], "a+" ) as file :
78+ session = aiohttp .ClientSession ()
79+ request = await session .post (choice (url ), data = {"gen" : "" }, timeout = self .config ["request-timeout" ] or 5 )
80+ await session .close ()
81+ outUrl = \
82+ findall ("http://.*" , str (BeautifulSoup (await request .text (), "html.parser" ).select (selector )))[0 ]
83+ await aprint (await self .make_beautiful (outUrl ))
84+ file .write ("%s" % outUrl )
8485
8586
8687if __name__ == '__main__' :
You can’t perform that action at this time.
0 commit comments