沙雕代码(我真的是无聊)

源代码(Python3)

需要requests,BeautifulSoup库

# -*- coding: cp936 -*-
"""
Created on Sat Jun 29 13:04:06 2019

@author: 兄主的仙人掌
"""

#输出:兄主的仙人掌是沙雕

import requests as rq
from bs4 import BeautifulSoup

url = 'https://xzdxrz.github.io/'

res = rq.get(url)

#print(res.text)

bs = BeautifulSoup(res.text,'lxml')

#print(type(bs.title))

name = str(bs.title)[7:13]

#print(name)

url = 'https://translate.google.cn/translate_a/single?client=webapp&sl=en&tl=zh-CN&hl=zh-CN&dt=at&dt=bd&dt=ex&dt=ld&dt=md&dt=qca&dt=rw&dt=rm&dt=ss&dt=t&source=bh&ssel=0&tsel=0&kc=1&tk=903126.743789&q=is'

res = rq.get(url)

#print(res.text)

ls = list(res.text)

#print(ls[4])

_is = ls[4]

#shadiao

url_fake = 'https://translate.google.cn/translate_a/single?client=webapp&sl=en&tl=zh-CN&hl=zh-CN&dt=at&dt=bd&dt=ex&dt=ld&dt=md&dt=qca&dt=rw&dt=rm&dt=ss&dt=t&source=bh&ssel=0&tsel=0&kc=1&tk=964014.535317&q='

sha = 'Sand'

diao = 'sculpture'

shadiao = sha + '%20' + diao

url_real = url_fake + shadiao

res = rq.get(url_real)

#print(str(res.text)[4:6])

chinese_shadiao = str(res.text)[4:6]

print(name + _is + chinese_shadiao)

两行版(Python3)

同样需要requests,BeautifulSoup库

import requests,bs4
print(str(bs4.BeautifulSoup(requests.get('https://xzdxrz.github.io/').text,'lxml').title)[7:13] + list(requests.get('https://translate.google.cn/translate_a/single?client=webapp&sl=en&tl=zh-CN&hl=zh-CN&dt=at&dt=bd&dt=ex&dt=ld&dt=md&dt=qca&dt=rw&dt=rm&dt=ss&dt=t&source=bh&ssel=0&tsel=0&kc=1&tk=903126.743789&q=is').text)[4] + str(requests.get('https://translate.google.cn/translate_a/single?client=webapp&sl=en&tl=zh-CN&hl=zh-CN&dt=at&dt=bd&dt=ex&dt=ld&dt=md&dt=qca&dt=rw&dt=rm&dt=ss&dt=t&source=bh&ssel=0&tsel=0&kc=1&tk=964014.535317&q=' + 'Sand' + '%20' + 'sculpture').text)[4:6])

分析

没有

你可能感兴趣的:(其它)