if isinstance(tr, bs4.element.Tag):
tds = tr(‘a’)
ulist.append([tds[0].string, tds[1].string, tds[2].string])
def printUnivList(ulist,k):
return ulist[k][0]
def getduanzi():
uinfo = []
k=1
u = ‘http://duanziwang.com/category/%E4%B8%80%E5%8F%A5%E8%AF%9D%E6%AE%B5%E5%AD%90/’
i=random.randint(1,49)
url=u+str(i)+‘/’
html = getHTMLText(url)
fillUnivList(uinfo, html)
k=random.randint(0,9)
return printUnivList(uinfo,k)
def fill2(ulist,html):
soup = BeautifulSoup(html, “html.parser”)
for tr in soup.find_all(‘div’,‘article block untagged mb15 typs_hot’):
if isinstance(tr, bs4.element.Tag):
tds = tr.find(‘div’,‘content’)
tdss=tds(‘span’)
reg = re.compile(‘<[^>]*>’)
text=reg.sub(‘’,str(tdss))
regg = re.compile(‘\[|\]|\n’)
text=regg.sub(‘’,text)
ulist.append(text)
def getjoke():
ulist=[]
u=‘https://www.qiushibaike.com/text/page/’
i=random.randint(1,13)
url=u+str(i)+‘/’
html=getHTMLText(url)
fill2(ulist,html)
k=random.randint(0,16)
#print(str(ulist[k]))
return str(ulist[k])
def getHTMLText2(url):
try:
r = requests.get(url, timeout=30)
r.raise_for_status()
r.encoding = r.apparent_encoding
return r.text
except:
return “”
def geturl(url,text):
html=getHTMLText2(url)
soup = BeautifulSoup(html, “html.parser”)
for tds in soup.find_all(‘a’):
#print(tds.string)
if str(tds.string) in text:
#print(tds.attrs[‘href’])
return tds.attrs[‘href’]
return ‘’
def getmoreurl(url):
html=getHTMLText2(url)
soup = BeautifulSoup(html, “html.parser”)
try:
li=soup.find_all(‘li’,attrs={‘class’:‘articleTitle fl’})
k=random.randint(0,len(li)-1)
return lik[0].attrs[‘href’]
except:
return ‘’
def getsen(url):
html=getHTMLText2(url)
soup = BeautifulSoup(html, “html.parser”)
try:
li=soup.find(‘p’)
reg = re.compile(‘
.*’)
l=reg.findall(str(li))
#print(l)
k=random.randint(0,len(l)-1)
text=re.findall(‘[\u4e00-\u9fa5]+’,l[k])
x=‘’
if len(text):
for t in text[:-2]:
x=x+t+‘,’
return x+text[-1]+‘。’
else:
return “不好意思,出了点小问题,请重试!”
except:
return “抱歉,没找到你想要的”
def getsentance(text):
start_url = ‘http://www.siandian.com’
urll=‘http://www.siandian.com/tags.html’
end1=geturl(urll,text)
if end1==‘’:
return “抱歉,没有找到你想要的。”
else:
end2=getmoreurl(start_url+end1)
if end2==‘’:
return “抱歉,没有找到你想要的。”
else:
#print(start_url+end2)
return getsen(start_url+end2)
def xiaotang(s):
sign=1;
while(sign):
if ‘段子’ in s:
while(‘段子’ in s or ‘继续’ in s or ‘再来’ in s or s==‘’):
return getduanzi()
elif ‘笑话’ in s:
while(‘笑话’ in s or ‘继续’ in s or ‘再来’ in s or s==‘’):
return getjoke()
elif ‘句’ in s or ‘话’ in s:
return getsentance(s)
elif ‘傻子’ in s or ‘草’ in s or ‘日’ in s:
return ‘这是脏话不可以说哦’
elif ‘二’ in s or ‘垃圾’ in s or ‘傻逼’ in s:
t=‘你是魔鬼吗?’
x=‘’
for i in range(10):
x=x+t+’ !‘+’\n’
return x
else:
return “我好像不明白\n”
def main():
def start():
strMsg = ‘小糖:’ + time.strftime(“%Y-%m-%d %H:%M:%S”,
time.localtime()) + '\n ’
txtget.insert(END, strMsg, ‘redcolor’)
txtget.insert(END, ‘你好,请问有什么可以帮忙的?’)
def sendMsg():#发送消息
t=txtMsg.get(‘0.0’, END)
txtMsg.delete(‘0.0’, END)
strMsg = ‘我:’ + time.strftime(“%Y-%m-%d %H:%M:%S”,
time.localtime()) + '\n ’
for i in range(int(txtget.index(END).split(“.”)[0])-int(txtMsgList.index(END).split(“.”)[0])+1):
txtMsgList.insert(END, ‘\n’)
txtMsgList.insert(END, strMsg, ‘greencolor’)
txtMsgList.insert(END, t)
txtMsgList.see(END)
for i in range(int(txtMsgList.index(END).split(“.”)[0])-int(txtget.index(END).split(“.”)[0])+1):
txtget.insert(END, ‘\n’)
txtget.see(END)
strMsg = ‘小糖:’ + time.strftime(“%Y-%m-%d %H:%M:%S”,
time.localtime()) + '\n ’
for i in range(int(txtMsgList.index(END).split(“.”)[0])-int(txtget.index(END).split(“.”)[0])+1):
txtget.insert(END, ‘\n’)
txtget.insert(END, strMsg, ‘redcolor’)
txtget.insert(END, xiaotang(t))
txtget.see(END)
for i in range(int(txtget.index(END).split(“.”)[0])-int(txtMsgList.index(END).split(“.”)[0])+1):
txtMsgList.insert(END, ‘\n’)
txtMsgList.see(END)
def cancelMsg():#取消消息
txtMsg.delete(‘0.0’, END)
def sendMsgEvent(event): #发送消息事件
sendMsg()
#创建窗口
t = Tk()
t.title(‘小糖助手’)
#创建frame容器
frmLT = Frame(width=500, height=320, bg=‘#F19C8B’)
frmLC = Frame(width=500, height=150, bg=‘#F19C8B’)
frmLB = Frame(width=500, height=30,bg=‘white’)
frmRT = Frame(width=200, height=500,bg=‘#F19C8B’)
#创建控件
txtMsgList = Text(frmLT,width=40,bd=0)
txtMsgList.tag_config(‘greencolor’, foreground=‘#008C00’)#创建tag
txtMsg = Text(frmLC)
txtget = Text(frmLT,width=40,bd=0)
txtget.tag_config(‘redcolor’, foreground=‘#DC143C’)#创建tag
start()
#txtMsg.bind(“”, sendMsgEvent)
txtMsg.bind(‘’,sendMsgEvent)
btnSend = Button(frmLB, text=‘发 送’, width = 8, command=sendMsg,bg=‘#E88384’,bd=0)
btnCancel = Button(frmLB, text=‘取消’, width = 8, command=cancelMsg,bg=‘#F3ADA0’,bd=0)
scollor=Scrollbar(bg=‘white’)
自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。
深知大多数Python工程师,想要提升技能,往往是自己摸索成长或者是报班学习,但对于培训机构动则几千的学费,着实压力不小。自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!
因此收集整理了一份《2024年Python开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。
既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上前端开发知识点,真正体系化!
由于文件比较大,这里只是将部分目录大纲截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且后续会持续更新
如果你觉得这些内容对你有帮助,可以扫码获取!!!(备注:Python)
884)]
既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上前端开发知识点,真正体系化!
由于文件比较大,这里只是将部分目录大纲截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且后续会持续更新
如果你觉得这些内容对你有帮助,可以扫码获取!!!(备注:Python)