- 博客(4)
- 资源 (1)
- 收藏
- 关注
原创 python翻译
首先引用requests及json import requests,json 下面我们给定有道的翻译链接,利用有道服务器进行翻译 url='http://fanyi.youdao.com/translate?smartresult=dict&smartresult=rule' 然后将相关参数封装在字典中,以防万一,设置请求头 headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.3
2020-08-05 18:01:52 185
原创 json的用法
Json模块用于字符串与字典的转换,如下所示: res=requests.post(url,headers=headers,data=data) #print(res.status_code) res_text=res.text #print(res_text) content = res.content.decode("utf8") #print(content) fanyi = json.loads(content) #print(fanyi) print('翻译结果是:') print(fanyi['
2020-08-05 17:52:03 103
原创 python 爬取电影
采用用户输入电影名字方式查找下载链接,主要用到beautiful soup、quote(转换成链接格式)、requests模块 import requests from bs4 import BeautifulSoup from urllib.request import quote #quote()函数,可以帮我们把内容转为标准的url格式,作为网址的一部分打开 movie = input('你想看什么电影呀?') gbkmovie = movie.encode('gbk') #将汉字,用gbk格式编码
2020-08-03 13:54:49 539
原创 python爬取图片
import requests res = requests.get('https://res.pandateacher.com/2019-01-12-15-29-33.png') ## 标题#发出请求,并把返回的结果放在变量res中 pic=res.content #把Reponse对象的内容以二进制数据的形式返回 photo = open('01练习作业2.jpg','wb') #新建了一个文件ppt.jpg,这里的文件没加路径,它会被保存在程序运行的当前目录下。 #图片内容需要以二进制wb读写。你在学
2020-07-31 15:22:04 182
song_list.py
2020-08-03
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人