美文网首页
大众点评页面抓取实例

大众点评页面抓取实例

作者: up_shang | 来源:发表于2017-01-01 21:13 被阅读0次

#coding:utf-8

import re

from bs4 import BeautifulSoup as bs

with open('dianping.html','rb') as f:

html = f.read().decode()

dianping = bs(html,'lxml')

allshops = dianping.find_all('div', attrs={'class':'shop-list J_shop-list shop-all-list'})[0]

shops = allshops.find_all('li')

for eachshop in shops:

name = eachshop.h4.string

shopurl = eachshop.a["href"]

try:

star = re.findall('title="(.*)">',str(eachshop.find_all('span')[0]))[0]

except:

star = ''

try:

cls = re.findall('(.*?)',str(eachshop.find_all('span')))[0]

except:

cls = ''

try:

area = re.findall('(.*?)',str(eachshop.find_all('span')))[1]

except:

area = ''

try:

addr = re.findall('(.*?)',str(eachshop.find_all('span')))[0]

except:

addr = ''

try:

comments = re.findall('(.*?)',str(eachshop.find_all('b')[0]))[0]

except:

comments = ''

try:

mean = re.findall('(.*?)',str(eachshop.find_all('b')[1]))[0]

except:

mean = ''

try:

taste = re.findall('(.*?)',str(eachshop.find_all('b')[2]))[0]

except:

taste = ''

try:

envior = re.findall('(.*?)',str(eachshop.find_all('b')[3]))[0]

except:

envior = ''

try:

service = re.findall('(.*?)',str(eachshop.find_all('b')[4]))[0]

except:

service = ''

print (name,shopurl,star,cls,area,addr,mean,taste,envior,service,comments)

相关文章

  • 大众点评页面抓取实例

    #coding:utf-8 import re from bs4 import BeautifulSoup as ...

  • 2018-04-01

    大众点评页面结构分析 本次我选择的垂直搜索App是大众点评。搜索页面分析包括大众点评首页和搜索结果页的分析。 大众...

  • Python抓取百度百科数据

    抓取策略 确定目标:确定抓取哪个网站的哪些页面的哪部分数据。本实例抓取百度百科python词条页面以及python...

  • Python抓取百度百科数据

    抓取策略 确定目标:确定抓取哪个网站的哪些页面的哪部分数据。本实例抓取百度百科python词条页面以及python...

  • 大众点评各城市热门餐厅数据爬虫抓取

    大众点评抓取 网址链接 http://www.dianping.com/shoplist/shopRank/pcC...

  • 大众点评评论抓取

    一、背景 大众点评评论部分还是值得我们关注的,因为我们上点评网看的也就是评论,通过评论抓取分析,也有利于我们对店铺...

  • 抓取大众点评商户数据

    大众点评商户数据还是有难度的,特别是美食类的,字体做了加密,网上很多资料自己看下即可。 之前是实时搜索抓取,需要登...

  • 从爬虫到数据可视化(2)—大众点评网

    本人是一名典型的吃货,所以今天想研究一下大众点评网上海美食的数据。 一、数据爬虫 首先是爬虫部分,由于大众点评页面...

  • 爬虫主要分三步

    抓取页面 分析页面 存储数据

  • curl 命令详解

    [TOC] 常用参数详解 常用curl实例 抓取页面内容到一个文件中 用 -O(大写的),后面的url要具体到某个...

网友评论

      本文标题:大众点评页面抓取实例

      本文链接:https://www.haomeiwen.com/subject/btbuvttx.html