
python爬虫
yyq675886993
这个作者很懒,什么都没留下…
展开
-
创建爬虫----复杂HTML解析
BeautifulSoup的find()和findAll()可通过标签的不同属性轻松的过滤HTML页面,查找需要的标签组或单个标签#findAll(tag,attributes,recursive,text,limit,keywords)#find(tag,attributes,recursive,text,keywords)#爬取大众点评的一页信息from urllib.request im原创 2017-06-30 15:45:00 · 400 阅读 · 0 评论 -
创建爬虫-----爬虫异常处理:
爬虫异常处理:from urllib.request import urlopenfrom urllib.error import HTTPError,URLErrorfrom bs4 import BeautifulSoupdef getTitle(url): try: html=urlopen(url) except(HTTPError,URLEr原创 2017-06-30 14:30:21 · 376 阅读 · 0 评论 -
创建爬虫----导航树
1.处理子标签和其他后代标签 孩子(child)和后代(descendant)from urllib.request import urlopenfrom bs4 import BeautifulSouphtml=urlopen("http://www.pythonscraping.com/pages/page3.html")bsObj=BeautifulSoup(html)for chil原创 2017-06-30 16:57:53 · 347 阅读 · 0 评论 -
创建爬虫----爬取大众点评数据并存入mongoDB数据库
#爬取大众点评多页数据from urllib.request import urlopenfrom bs4 import BeautifulSoupimport pymongoclient = pymongo.MongoClient('localhost',27017)dzdp = client['dzdp']url_list = dzdp['url_list']item_info =原创 2017-07-01 16:48:42 · 731 阅读 · 0 评论 -
创建爬虫----遍历单个域名爬取赶集网
爬取赶集网的页面链接#赶集网首页静态页面的链接爬取from urllib.request import urlopenfrom bs4 import BeautifulSoupimport rehtml=urlopen("http://ty.ganji.com/")bsObj=BeautifulSoup(html)for link in bsObj.find("div",{"class":"原创 2017-06-30 21:42:02 · 1037 阅读 · 0 评论