forked from p3t2ja9zs/dcs
parent
3aa4f82882
commit
a24d80c675
@ -0,0 +1,24 @@
|
||||
2022-03-16 15:28:49.544 | INFO | __main__:<module>:8 - reading config args...
|
||||
2022-03-16 15:28:49.544 | INFO | __main__:<module>:15 - starting the server...
|
||||
2022-03-16 15:28:52.463 | INFO | dcs.tests.requestHandler:run:21 - [REQUEST] test
|
||||
2022-03-16 15:28:52.464 | INFO | dcs.tests.requestHandler:run:31 - [RESPONSE] test: hello TEST, header size: 22
|
||||
2022-03-16 15:28:52.464 | INFO | dcs.tests.server:run:37 - [REQUEST] end
|
||||
2022-03-16 15:28:52.465 | WARNING | dcs.tests.server:run:38 - communication over!
|
||||
2022-03-16 15:28:52.465 | WARNING | __main__:<module>:21 - Overing...
|
||||
2022-03-16 15:29:18.818 | INFO | __main__:<module>:8 - reading config args...
|
||||
2022-03-16 15:29:18.819 | INFO | __main__:<module>:15 - starting the server...
|
||||
2022-03-16 15:29:21.915 | INFO | dcs.tests.requestHandler:run:21 - [REQUEST] test
|
||||
2022-03-16 15:29:21.915 | INFO | dcs.tests.requestHandler:run:31 - [RESPONSE] test: hello TEST, header size: 22
|
||||
2022-03-16 15:29:21.916 | INFO | dcs.tests.server:run:37 - [REQUEST] end
|
||||
2022-03-16 15:29:21.916 | WARNING | dcs.tests.server:run:38 - communication over!
|
||||
2022-03-16 15:29:21.916 | WARNING | __main__:<module>:21 - Overing...
|
||||
2022-03-16 15:55:33.304 | INFO | __main__:<module>:8 - reading config args...
|
||||
2022-03-16 15:55:33.304 | INFO | __main__:<module>:15 - starting the server...
|
||||
2022-03-16 15:55:41.001 | INFO | dcs.tests.requestHandler:run:21 - [REQUEST] test
|
||||
2022-03-16 15:55:41.002 | INFO | dcs.tests.requestHandler:run:31 - [RESPONSE] test: hello TEST, header size: 22
|
||||
2022-03-16 15:56:16.305 | INFO | dcs.tests.requestHandler:run:33 - [REQUEST] translate
|
||||
2022-03-16 15:56:16.305 | INFO | dcs.tests.spider:run:32 - crawling...
|
||||
2022-03-16 15:56:17.145 | INFO | dcs.tests.requestHandler:run:44 - [RESPONSE] translate: Life is too short, time is like a boat, header size: 55
|
||||
2022-03-16 15:56:17.146 | INFO | dcs.tests.server:run:36 - [REQUEST] end
|
||||
2022-03-16 15:56:17.147 | WARNING | dcs.tests.server:run:37 - communication over!
|
||||
2022-03-16 15:56:17.149 | WARNING | __main__:<module>:21 - Overing...
|
@ -0,0 +1,34 @@
|
||||
import threading
|
||||
import requests
|
||||
from loguru import logger
|
||||
|
||||
|
||||
def crawl(word):
|
||||
url = 'http://fanyi.youdao.com/translate?smartresult=dict&smartresult=rule'
|
||||
data = {'i': word,
|
||||
'from': 'AUTO',
|
||||
'to': 'AUTO',
|
||||
'smartresult': 'dict',
|
||||
'client': 'fanyideskweb',
|
||||
'doctype': 'json',
|
||||
'version': '2.1',
|
||||
'keyfrom': 'fanyi.web',
|
||||
'action': 'FY_BY_REALTIME',
|
||||
'typoResult': 'false'}
|
||||
r = requests.post(url, data)
|
||||
answer = r.json()
|
||||
result = answer['translateResult'][0][0]['tgt']
|
||||
return result
|
||||
|
||||
|
||||
class Spider(threading.Thread):
|
||||
def __init__(self, word: 'string'):
|
||||
super().__init__()
|
||||
self.word = word
|
||||
self.daemon = True
|
||||
pass
|
||||
|
||||
def run(self) -> None:
|
||||
logger.info('crawling...')
|
||||
return crawl(self.word)
|
||||
|
@ -1 +1,2 @@
|
||||
吴法院
|
||||
loguru~=0.6.0
|
||||
requests~=2.27.1
|
Loading…
Reference in new issue