@author:blues
@date:2020.9.8
```python
import hashlib
import time
import random
import requests
headers=
def func(word):
r = str(int(time.time()*1000))#1599574041
t=hashlib.md5(ua.encode('utf-8')).hexdigest()
i=str(int(r)+random.randint(0,9))
return
def data(word):
r=func(word)
return
def run():
url =""
word = input()
if (word=="exit()"):
exit()
response = requests.post(url, headers=headers, data=data(word))
try:
content = response.json()['translateresult'][0][0]
sentences = response.json()['translateresult'][0]
tgt = content['tgt']
src = content['src']
if response.json()['smartresult']:
means = response.json()['smartresult']['entries']
print(f"\n\n查詢:\n翻譯:")
for i in means[1:]:
print("\t",i,end="")
print("\n\n")
except:
try:
print("\n\n")
for sentence in sentences:
print(f"查詢:\n翻譯:")
print("\n\n")
except:
print("\n\n不存在該單詞\n\n")
if __name__ =="__main__":
print("-" * 50)
print("支援中文-》英文的單詞和句子")
print("支援英文-》中文的單詞和句子")
print("翻譯指令碼軟體,退出請輸入exit()")
print("@author:blues")
print("@version:1.0.4 @date:2020.09.09")
print("@僅供學習參考,概不負責")
print("-" * 50)
while(true):
print("#:", end="")
run()
爬蟲 有道翻譯
import time import requests import hashlib class youdaofanyi def get cookie self url ret requests.get url url return ret.headers.get set cookie def tr...
有道翻譯 爬蟲
目標 user agent身份驗證 請求頭設定 請求體資料 傳送請求並接收響應 接收資料簡單處理 在抓包工具中找到目標 或者在瀏覽器開發者工具中找到 不要找錯了 user agent身份資訊,這個比較簡單請求頭內容用抓包工具可以獲得抓包工具中的body表單 一般都是json格式的資料pycharm中...
爬蟲二 有道翻譯
import time,random,json from func all import post md5加密函式 defmd5 need str import hashlib 建立md5物件 md5 o hashlib.md5 需要有bytes,作為引數 sign bytes need str.e...