爬取中国旅游网首页
import requests;
content = requests.get('http://www.cntour.cn/');
print(content.text);
结果
爬取有道翻译,翻译“我在北京”为英文
import requests;
import json;
From_data = {'i': '我在北京', 'from': 'zh-CHS', 'to': 'en', 'smartresult': 'dict', 'client': 'fanyideskweb',
'salt': '16092986595130', 'sign': 'fd22a69d02244600c2173ee01bb6c518', 'lts': '1609298659513',
'bv': '4f7ca50d9eda878f3f40fb696cce4d6d', 'doctype': 'json', 'version': '2.1', 'keyfrom': 'fanyi.web',
'action': 'FY_BY_REALTIME'}
content = requests.post('http://fanyi.youdao.com/translate?smartresult=dict&smartresult=rule', data=From_data);
data = json.loads(content.text);
print(data['translateResult'][0][0]['tgt']);
结果