哇塞,大学本科四年的时光就这样结束了,虽然做毕设的整个过程并不是特别煎熬,也没有像别人一样熬夜写代码,但是通过毕设我确实了解很多计算机相关知识,现在进行一个简单的总结: 目录 学会了python的基本使用,包含其中的numpy、pandas、jieba、sqlite、re等各式各样的库 开始接触算法的应用和创新,在毕设设计到了TF-IDF算法、朴素贝叶斯分类、蚁群算法 学会了网络爬虫,本次毕设使用的是beautifulsoup4v 现在目录上的章节如果有时间会进行详细的文章编写,目前暂时只完成了网络爬虫部分。 由于本次在研究中需要对模型的应用进行一个更好的可视化展示效果,我做了两个简单的开发界面,第一个是旅游界面的推荐,第二个是推荐后得到的结果。 自从使用了python以后,才发现python是真的很好用哈,基本可以使用python进行编程了。 这些算法还是真的神奇,佩服数学的神奇! 第一次爬虫额,成功的爬取到了携程网的酒店、景点、美食信息。 其中本次爬虫的主要思想是:首先是找到携程网url的编写规律,然后根据规律使用beautifulsoup4对所需的html语言中的信息提取,最后就是封装处理。 如下是我爬取美食的代码,貌似景点和酒店已经我写的代码已经爬不了了。其具体代码在使用python爬取携程网旅游信息(包含景点、酒店、美食) 所以爬虫还是挺有意思的。 这两个话题虽然比较大,但是我还是想简单说一下自己的理解
了解基于django的web开发
学会了python的基本使用,包含其中的numpy、pandas、jieba、sqlite、re等各式各样的库
开始接触算法的应用和创新,在毕设设计到了TF-IDF算法、朴素贝叶斯分类、蚁群算法
学会了网络爬虫,本次毕设使用的是beautifulsoup4
# -*- coding: utf-8 -*- import requests import io from bs4 import BeautifulSoup as BS import time import re """从网上爬取数据""" headers = { "Origin": "https://piao.ctrip.com", "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36", } places=["beijing1","shanghai2","changsha148","sanya61","chongqing158","hongkong38","chengdu104","haerbin151", "xian7","guangzhou152","hangzhou14"] placenames=["北京","上海","长沙","三亚","重庆","香港","成都","哈尔滨","西安","广州","杭州"] places=["changsha148"] placenames=["长沙"] base="https://you.ctrip.com/fooditem/"; base2="https://you.ctrip.com"; requestlist=[] for j in range(len(places)): #爬取对应的特色菜 requestlist.append({"url":base+places[j]+".html","place":placenames[j]}) for i in range(2,2): tmp=base+places[j]+"/s0-p"+str(i)+".html" requestlist.append({"url":tmp,"place":placenames[j]}); #对应的url地址和所查询的位置 print(requestlist) l=[] count=1; for i in range(len(requestlist)): response = requests.get(requestlist[i]["url"], headers=headers) #print(response) html=response.text #print(html) soup=BS(html,'html.parser') vs=soup.find_all(name="div",attrs={"class":"rdetailbox"}) print("len(vs)",len(vs)) for j in range(len(vs)): print("正在打印的条数:",j) try: #获取子网页链接地址 href=vs[j].find(name="a",attrs={"target":"_blank"}).attrs["href"]; #print("href",href) # 再次请求子网页,获取景点详细信息 res = requests.get(base2+href, headers=headers) print("当前访问的网址:",base2+href) with open("3.html","w",encoding="utf-8") as f: f.write(res.text) soupi = BS(res.text,"html.parser") #该网页的html代码 #print(soupi) vis = soupi.find_all(name="li",attrs={"class":"infotext"}); #获取此时的dom文件位置所在 #print(vis) introduce=[] for i in range(len(vis)): introduce.append(vis[i].get_text()) imgs=[]; imglinks=soupi.find_all(name="a",attrs={"href":"javascript:void(0)"}) #print(imte) # print(imglinks) # print(type(imglinks)) #for img in imte: #imgs.append(img.attrs["src"]) tmp={}; tmp["id"]=count; tmp["name"]=vs[j].find(name="a",attrs={"target":"_blank"}).string; tmp["name"]=tmp["name"].replace(" ","").replace("n",""); tmp["introduce"]=introduce tmp["img"]=imglinks tmp["city"]=requestlist[i]["place"] count=count+1; l.append(tmp); time.sleep(1); except Exception as e: print(e) pass #print ("打印tmp",tmp) # with open("datap/"+tmp["name"]+".pk",'wb') as f: # pickle.dump(tmp,f); with io.open("/Users/hujinhong/PycharmProjects/untitled5/food/changsha/"+tmp["name"]+".txt",'w',encoding="utf-8") as f: f.write(str(tmp)) #print(l) for i in l: print((i)) # # browser.close()#关闭浏览器 # with open("data2.txt",'w',encoding='utf-8') as f: # f.write(str(l)) # with open("data2.pk","w",encoding="utf-8") as f: # pickle.dump(l,f); #https://hotels.ctrip.com/hotel/qingdao7/star2/k1%E4%BA%94%E5%9B%9B%E5%B9%BF%E5%9C%BA#ctm_ref=ctr_hp_sb_lst
接触了数据挖掘、基于内容的推荐
本网页所有视频内容由 imoviebox边看边下-网页视频下载, iurlBox网页地址收藏管理器 下载并得到。
ImovieBox网页视频下载器 下载地址: ImovieBox网页视频下载器-最新版本下载
本文章由: imapbox邮箱云存储,邮箱网盘,ImageBox 图片批量下载器,网页图片批量下载专家,网页图片批量下载器,获取到文章图片,imoviebox网页视频批量下载器,下载视频内容,为您提供.
阅读和此文章类似的: 全球云计算