App的数据如何用python抓取
- 使用抓包工具
- 手机使用代理,app所有请求通过抓包工具
- 获得接口,分析接口
- 反编译apk获取key
- 突破反爬限制
- 夜神模拟器
- Fiddler
- Pycharm


- 夜神模拟器下载完成之后,傻瓜式的安装一下!
- 首先将当前手机网络桥接到本电脑网络 实现互通


- 打开主机cmd






部分python代码分享:
import requests
import city
import json
import jsonpath
import re
city_list = city.jsons
tags_list = city.Tag
def city_func(city_id):
try:
city = jsonpath.jsonpath(city_list, '$..sub[?(@.code=={})]'.format(int(city_id)))[0]["name"]
except:
city = jsonpath.jsonpath(city_list, '$[?(@.code=={})]'.format(int(city_id)))[0]["name"]
return city
def tags_func(tags_id):
tags_join = []
if tags_id:
for tags in tags_id:
t = jsonpath.jsonpath(tags_list,'$..spotFilterTags[?(@.id=={})]'.format(int(tags)))
tags_join.append(t[0]["title"])
return ('-'.join(tags_join))
def split_n(ags):
return re.sub('\n',' ',ags)
def request(page):
print('开始下载第%d页'%page)
url = 'https://app-api.chargerlink.com/spot/searchSpot'
two_url = "https://app-api.chargerlink.com/spot/getSpotDetail?spotId={d}"
head = {
"device": "client=android&cityName=%E5%8C%97%E4%BA%AC%E5%B8%82&cityCode=110106&lng=116.32154281224254&device_id=8A261C9D60ACEBDED7CD3706C92DD68E&ver=3.7.7&lat=39.895024107858724&network=WIFI&os_version=19",
"appId": "20171010",
"timestamp": "1532342711477",
"signature": "36daaa33e7b0d5d29ac9c64a2ce6c4cf",
"forcecheck": "1",
"Content-Type": "application/x-www-form-urlencoded",
"Content-Length": "68",
"Host": "app-api.chargerlink.com",
"Connection": "Keep-Alive",
"User-Agent": "okhttp/3.2.0"
}
data = {
"userFilter[operateType]": 2,
"cityCode": 110000,
"sort": 1,
"page": page,
"limit": 10,
}
response = requests.post(url,data=data,headers=head)
#获取数据
data = response.json()
for i in data['data']:
c = []
id = i['id']
name = i["name"] #充电桩名
phone = i["phone"] #手机号
num = i['quantity'] #有几个充电桩
city = city_func(i["provinceCode"]) #城市
tags =tags_func(i["tags"].split(','))#标签
message = c + [id,name,phone,num,city,tags]
parse_info(two_url.format(d=id),message)
def parse_info(url,message):
#打开文件
with open('car.csv','a',encoding='utf-8')as c:
head = {
"device": "client=android&cityName=&cityCode=&lng=116.32154281224254&device_id=8A261C9D60ACEBDED7CD3706C92DD68E&ver=3.7.7&lat=39.895024107858724&network=WIFI&os_version=19",
"TOKEN": "036c8e24266c9089db50899287a99e65dc3bf95f",
"appId": "20171010",
"timestamp": "1532357165598",
"signature": "734ecec249f86193d6e54449ec5e8ff6",
"forcecheck": "1",
"Host": "app-api.chargerlink.com",
"Connection": "Keep-Alive",
"User-Agent": "okhttp/3.2.0",
}
#发起详情请求
res = requests.get(url,headers=head)
price = split_n(jsonpath.jsonpath(json.loads(res.text),'$..chargingFeeDesc')[0]) #价钱
payType = jsonpath.jsonpath(json.loads(res.text),'$..payTypeDesc')[0] #支付方式
businessTime =split_n(jsonpath.jsonpath(json.loads(res.text),'$..businessTime')[0]) #营业时间
result = (message + [price,payType,businessTime])
r = ','.join([str(i) for i in result])+',\n'
c.write(r)
def get_page():
url = 'https://app-api.chargerlink.com/spot/searchSpot'
head = {
"device": "client=android&cityName=%E5%8C%97%E4%BA%AC%E5%B8%82&cityCode=110106&lng=116.32154281224254&device_id=8A261C9D60ACEBDED7CD3706C92DD68E&ver=3.7.7&lat=39.895024107858724&network=WIFI&os_version=19",
"appId": "20171010",
"timestamp": "1532342711477",
"signature": "36daaa33e7b0d5d29ac9c64a2ce6c4cf",
"forcecheck": "1",
"Content-Type": "application/x-www-form-urlencoded",
"Content-Length": "68",
"Host": "app-api.chargerlink.com",
"Connection": "Keep-Alive",
"User-Agent": "okhttp/3.2.0"
}
data = {
"userFilter[operateType]": 2,
"cityCode": 110000,
"sort": 1,
"page": 1,
"limit": 10,
}
response = requests.post(url, data=data, headers=head)
# 获取数据
data = response.json()
total = (data["pager"]["total"])
page_Size = (data["pager"]["pageSize"])
totalPage = (data['pager']["totalPage"])
print('当前共有{total}个充电桩,每页展示{page_Size}个,共{totalPage}页'.format(total=total,page_Size=page_Size,totalPage=totalPage))
if __name__ == '__main__':
get_page()
start = int(input("亲,请输入您要获取的开始页:"))
end = int(input("亲,请输入您要获取的结束页:"))
for i in range(start,end+1):
request(i)




App的数据如何用python抓取的更多相关文章
- 如何用python抓取js生成的数据 - SegmentFault
如何用python抓取js生成的数据 - SegmentFault 如何用python抓取js生成的数据 1赞 踩 收藏 想写一个爬虫,但是需要抓去的的数据是js生成的,在源代码里看不到,要怎么才能抓 ...
- (转)如何用python抓取网页并提取数据
最近一直在学这部分,今日发现一篇好文,虽然不详细,但是轮廓是出来了: 来自crifan:http://www.crifan.com/crawl_website_html_and_extract_inf ...
- 使用 Python 抓取欧洲足球联赛数据
Web Scraping在大数据时代,一切都要用数据来说话,大数据处理的过程一般需要经过以下的几个步骤 数据的采集和获取 数据的清洗,抽取,变形和装载 数据的分析,探索和预测 ...
- 关于python抓取google搜索结果的若干问题
关于python抓取google搜索结果的若干问题 前一段时间一直在研究如何用python抓取搜索引擎结果,在实现的过程中遇到了很多的问题,我把我遇到的问题都记录下来,希望以后遇到同样问题的童 ...
- Python抓取百度百科数据
前言 本文整理自慕课网<Python开发简单爬虫>,将会记录爬取百度百科"python"词条相关页面的整个过程. 抓取策略 确定目标:确定抓取哪个网站的哪些页面的哪部分 ...
- 使用python抓取并分析数据—链家网(requests+BeautifulSoup)(转)
本篇文章是使用python抓取数据的第一篇,使用requests+BeautifulSoup的方法对页面进行抓取和数据提取.通过使用requests库对链家网二手房列表页进行抓取,通过Beautifu ...
- 使用Python抓取猫眼近10万条评论并分析
<一出好戏>讲述人性,使用Python抓取猫眼近10万条评论并分析,一起揭秘“这出好戏”到底如何? 黄渤首次导演的电影<一出好戏>自8月10日在全国上映,至今已有10天,其主演 ...
- python抓取网页例子
python抓取网页例子 最近在学习python,刚刚完成了一个网页抓取的例子,通过python抓取全世界所有的学校以及学院的数据,并存为xml文件.数据源是人人网. 因为刚学习python,写的代码 ...
- Python抓取页面中超链接(URL)的三中方法比较(HTMLParser、pyquery、正则表达式) <转>
Python抓取页面中超链接(URL)的3中方法比较(HTMLParser.pyquery.正则表达式) HTMLParser版: #!/usr/bin/python # -*- coding: UT ...
随机推荐
- asp.net net::ERR_ABORTED 500 (Internal Server Error) 无法加载JS CSS等文件的解决方法
网站换服务器,部署上去后打开首页,js .css等文件始终无法加载,经过排查,问题出现在web.config文件中. <defaultDocument> <files> < ...
- C#中的9个“黑魔法”与“骚操作”
C#中的9个"黑魔法"与"骚操作" 我们知道C#是非常先进的语言,因为是它很有远见的"语法糖".这些"语法糖"有时过于好 ...
- element-ui 的 单选按钮(Radio) 怎么取消文本显示?
方法一:<el-radio class="radio" v-model="radio" :label="1"> </el- ...
- 关于利用python进行验证码识别的一些想法
转载:@小五义http://www.cnblogs.com/xiaowuyi 用python加“验证码”为关键词在baidu里搜一下,可以找到很多关于验证码识别的文章.我大体看了一下,主要方法有几类: ...
- TensorFlow 训练好模型参数的保存和恢复代码
TensorFlow 训练好模型参数的保存和恢复代码,之前就在想模型不应该每次要个结果都要重新训练一遍吧,应该训练一次就可以一直使用吧. TensorFlow 提供了 Saver 类,可以进行保存和恢 ...
- PHP7内核(三):源码目录结构
上篇文章我们已经介绍了源码分析工具的安装.配置以及调试方法,本文我们来讲述一下PHP源码的目录结构. 一.目录概览 以php-7.0.12为例,看过源码的同学们应该发现源码目录多达十多个,下面是每个目 ...
- 双剑合璧的开源项目Kitty-Cloud
项目地址 https://github.com/yinjihuan/kitty-cloud 背景 做这个项目主要是想将个人的一些经验通过开源的形式进行输出,不一定能帮到所有人,有感兴趣的朋友可以关注学 ...
- 磅日波浪分析4H 20190927
磅日的短线调整预计在132结束 目前已显现出ABC调整末端. 未来预计开启第五浪升势 破前期反弹高点.
- 解决浏览器看不到Flash文档(尤其某慕课)
最近遇到很多朋友说浏览器看不到网课资源的文档等等,就顺手写一篇说一下情况 为什么会文档空白 某课网站上面的文档是用flash进行展示的,同时flash被很多浏览器逐步抛弃(快凉了,都是H5了) fla ...
- 1050 String Subtraction (20分)
Given two strings S1 and S2, S=S1−S2 is defined to be the remaining string after taking ...