python爬虫入门教程——爬取360翻译

编程知识 行业动态 更新时间:2024-06-13 00:19:22

python爬虫入门教程之爬取360翻译,

使用requests模块和json模块,通过分析360翻译的网络请求,通过Python实现将其结果爬取。

'''
Python爬取360翻译
'''
import requests
import json
query = input('请输入你要翻译的内容:')
url = 'http://fanyi.so/index/search'
query_string = {"query": query,"eng": "0","validate": ""}
headers = {"user-agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1"}
response = requests.post(url=url,data=query_string,headers=headers)
response.encoding = 'utf-8'
dict_ret = json.loads(response.text)
print(dict_ret['data']['fanyi'])

 

更多推荐

python爬虫入门教程——爬取360翻译

本文发布于:2023-03-28 06:01:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/f5988eb335c7525a9571da7ab6c746d6.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:爬虫   入门教程   python

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!