用python爬虫爬取百度外卖店铺排名
2016-08-01 13:07
585 查看
#!/usr/bin/env python # encoding: utf-8 """ @version: ?? @author: phpergao @license: Apache Licence @file: baidu_paiming.py @time: 2016/8/1 11:10 """ import requests,re,urllib,codeop,urllib.request,nturl2path,macurl2path urllist = ["f7a2bee997ef68e8", # 丽影 "3b246a0864597e50", # 穗丰 "0ebf88697141f32f", # 冠城 "eff209d4a7f538ca", # 礼岗 "57f9e38e087acf61", # 购书 ] def chapaiming(urllist): User_Agent = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36"#伪装成浏览器访问 headers = ('User-Agent', User_Agent) opener = urllib.request.build_opener() opener.addheaders = [headers] num0=1 num=1 flag=True while flag: url="http://waimai.baidu.com/waimai/shoplist/{}?display=json&page={}&count=40".format(urllist,num0) num0 += 1 ret = opener.open(url) #ret =urllib.request.urlopen(url) ret=ret.read().decode('unicode_escape') html = re.findall(r'''"shop_name":"(.*?)","shop_announcement":''', ret) address=re.findall(r'''"poi_address":"(.*?)"},"sortby":''',ret) for i in html: num += 1 if '72' in str(i): print(i,"排名在:{},定位地址:{}".format(num,address)) num0 = 1 flag=False break #print(i) if __name__=="__main__": for i in urllist: chapaiming(i)
相关文章推荐
- 用python爬虫爬取饿了么外卖店铺排名
- python3.x爬虫:爬取大学排名数据
- [置顶] [爬虫]使用python抓取京东全站数据(商品,店铺,分类,评论)
- [置顶] 【python 淘宝爬虫】python 淘宝店铺名称,旺旺,销售量 抓取
- python爬虫学习 之 定向爬取 中国大学排名
- python爬虫由浅入深7--基于中国大学排名的定向爬虫
- 第一个简单的python爬虫:爬取ATP男子网球世界排名
- Python网络爬虫与信息提取-Day10-(实例)中国大学排名定向爬虫
- Python爬虫实现抓取京东店铺信息及下载图片功能示例
- python 爬虫爬取几十家门店在美团外卖上的排名,并插入数据库,最后在前端显示
- Python爬虫实战:2017中国最好大学排名
- python爬虫定向爬取中国大学排名
- python 爬虫 大众点评美食排名
- python 网络爬虫代码
- phpsir 开发 一个检测百度关键字网站排名的python 程序
- Tiobe 发布2011年2月开发语言排名,C#和Python在2011年继续上升
- 【转帖】用python爬虫抓站的一些技巧总结
- 【用Python写爬虫】获取html的方法【五】:利用Twisted框架之client.getPage
- Python写爬虫抓站的一些技巧