KFC 小猪短租
# 分析肯德基门店信息
import requests,json
post_url = 'http://www.kfc.com.cn/kfccda/ashx/GetStoreList.ashx?op=cname'
headers = {'User-Agent':'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.81 Safari/537.36'}
all_data = []
IDs =[]
cname = input('输入城市名: ')
# for page in range(1,10):
data = {
"cname": cname,
"pid": "",
"pageIndex": "",
"pageSize": "",
}
json_obj = requests.post(url=post_url,data=data,headers=headers).json()
num = json_obj['Table'][0]['rowcount'] # 餐厅总数 int
print("餐厅总数",num) 小贴士: 运行后,输入城市或省份地址,得到肯德基门店数量
# 小猪短租
from bs4 import BeautifulSoup
import requests
import time
headers = {'User-Agent':'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.81 Safari/537.36'}
def judgment_sex(class_name):
if class_name == ['member_ico1']:
return '女'
else:
return '男' def get_links(url):
wb_data = requests.get(url, headers= headers)
soup = BeautifulSoup( wb_data. text,'lxml')
links = soup. select('#page_list > ul > li > a')
for link in links:
href = link. get("href")
get_info(href) def get_info(url):
wb_data = requests.get( url, headers= headers)
soup = BeautifulSoup( wb_data.text,'lxml')
tittles = soup. select('div.pho_info > h4')
addresses = soup.select('span.pr5')
prices = soup.select('#pricePart > div.day_l > span')
imgs = soup.select('#floatRightBox > div.js_box.clearfix > div.member_pic > a > img')
names = soup.select('#floatRightBox > div.js_box.clearfix > div.w_240 > h6 > a')
sexs = soup.select('#floatRightBox > div.js_box.clearfix > div.member_pic > div')
for tittle, address, price, img, name, sex in zip( tittles, addresses, prices, imgs, names, sexs):
data = { 'tittle': tittle.get_text().strip(),
'address': address.get_text().strip(),
'price': price.get_text(),
'img': img.get("src"),
'name': name.get_text(),
'sex': judgment_sex(sex.get("class"))}
print(data)
if __name__ == '__main__':
urls = ['http://ty.xiaozhu.com/search-duanzufang-p{}-0/'.format(number) for number in range(1,14)]
for single_url in urls:
get_links(single_url)
time.sleep(0.3)
# 酷狗500歌曲
from bs4 import BeautifulSoup
import requests
import time
headers = {'User-Agent':'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.81 Safari/537.36'}
def judgment_sex(class_name):
if class_name == ['member_ico1']:
return '女'
else:
return '男' def get_info(url):
wb_data = requests.get( url, headers= headers)
soup = BeautifulSoup( wb_data.text,'lxml')
ranks = soup.select('span.pc_temp_num')
titles = soup.select('div.pc_temp_songlist > ul > li > a')
times = soup.select(' span.pc_temp_tips_r > span') for rank,title,time in zip(ranks,titles,times):
data = { 'rank': rank.get_text().strip(),
'singer': title.get_text().split('-')[0],
'song': title.get_text().split('-')[1],
'time': time.get_text().strip()}
print(data)
if __name__ == '__main__':
urls = ['http://www.kugou.com/yy/rank/home/{}-8888.html'.format(number) for number in range(1,24)]
for single_url in urls:
get_info(single_url)
time.sleep(0.3)
酷狗500
import re
a = 'xxIxxjshdxxlovexxsffaxxpythonxx'
infos = re.findall('xx(.*?)xx',a,re.S)
print(infos)
# ['I', 'love', 'python']
re 一个
import re
phone = '''
123.-4,567,1234,jdd,cdc.23,the
wfewf ,fer3t
'''
new_phone = re.sub("\d+",' ', phone)
aa = re.sub('\W+',' ',new_phone)
print(aa)
re匹配数字标点符号
KFC 小猪短租的更多相关文章
- python3通过Beautif和XPath分别爬取“小猪短租-北京”租房信息,并对比时间效率(附源代码)
爬虫思路分析: 1. 观察小猪短租(北京)的网页 首页:http://www.xiaozhu.com/?utm_source=baidu&utm_medium=cpc&utm_term ...
- 短租app简析
本人应聘某短租app产品经理时做的材料,贴出来请高手指教. 所有内容来自公开资料,不涉及商业秘密.
- Python爬虫:设置Cookie解决网站拦截并爬取蚂蚁短租
前言 文的文字及图片来源于网络,仅供学习.交流使用,不具有任何商业用途,版权归原作者所有,如有问题请及时联系我们以作处理. 作者: Eastmount PS:如有需要Python学习资料的小伙伴可以加 ...
- 看完你也能独立负责项目!产品经理做APP从头到尾的所有工作流程详解!
(一)项目启动前 从事产品的工作一年多,但自己一直苦于这样或者那样的困惑,很多人想要从事产品,或者老板自己创业要亲自承担产品一职,但他们对产品这个岗位的认识却不明晰,有的以为是纯粹的画原型,有的是以为 ...
- 爬虫系列3:Requests+Xpath 爬取租房网站信息并保存本地
数据保存本地 [抓取]:参考前文 爬虫系列1:https://www.cnblogs.com/yizhiamumu/p/9451093.html [分页]:参考前文 爬虫系列2:https://www ...
- 新加坡金融科技节 | 蚂蚁金服CTO程立:面向全球开放,与合作伙伴共赢
小蚂蚁说: 11月13日,在新加坡金融科技节上,蚂蚁金服CTO程立分别从TechFin.BASIC战略.SOFAStack全栈分布式体系以及全面开放等方面讲述蚂蚁金融科技. TechFin是一种“倒立 ...
- @1-4使用Xpath解析豆瓣短评
使用Xpath解析豆瓣短评 Python爬虫(入门+进阶) DC学院 本节课程主要介绍解析神器Xpath是什么.Xpath如何安装及使用,以及使用实际的例子讲解Xpath如何解析豆瓣短评的网页 ...
- 数据分析侠A的成长故事
数据分析侠A的成长故事 面包君 同学A:22岁,男,大四准备实习,计算机专业,迷茫期 作为一个很普通的即将迈入职场的他来说,看到周边的同学都找了技术开发的岗位,顿觉自己很迷茫,因为自己不是那么喜欢钻 ...
- python3爬取咪咕音乐榜信息(附源代码)
参照上一篇爬虫小猪短租的思路https://www.cnblogs.com/aby321/p/9946831.html,继续熟悉基础爬虫方法,本次爬取的是咪咕音乐的排名 咪咕音乐榜首页http://m ...
随机推荐
- javascript当中prototype用法
prototype见上一节,马克-to-win:prototype作用就是给某个类增加一个实例方法. 例 3.6.2 <head> <meta http-equiv=" ...
- 【SQL】基础概念
1.. In order to find the rows where the value for a column is or is not NULL, you would use IS NULL ...
- linux添加新的环境变量
Linux下设置PYTHONPATH环境变量有三种方法:一种作用于当前终端,一种作用于当前用户,一种作用于所有用户. 1.作用于当前终端,直接当前终端输入命令 $ export PYTHONPATH= ...
- ubuntu18+caffe+cuda
昨天安装caffe,因为用的是cuda10.2,遇到各种问题,最终也没有安装成功.使用cmake配置成功.生成成功.编译的时候报错. /usr/local/cuda/include/cuda_runt ...
- oneshot和周期性shot
计数器的使用,oneshot:时刻. 有误差,日.每一些间隔可以产生周期性shot(多个持续性时刻)
- oracle 处理锁表,创建新的数据库实例
select saddr,sid,serial#,paddr,username,status from v$session where username is not null and usernam ...
- Linux system 初步
快捷键: open a new terminal: ctrl+alt+T; close current terminal: ctrl+shift+W; switch windows: alt+tab ...
- SpringBoot开发快速入门
SpringBoot开发快速入门 目录 一.Spring Boot 入门 1.Spring Boot 简介 2.微服务 3.环境准备 1.maven设置: 2.IDEA设置 4.Spring Boot ...
- codeforces 1282 E. The Cake Is a Lie (dfs+构造)
链接:https://codeforces.com/contest/1282/problem/E 题意:给的是一张平面图,是一个n边形,每次可以切一刀,切出一个三角形,最终切成n-2个三角形.题目给出 ...
- Windows下编译Google.Protobuf在Qt(C++)中使用与Unity3d(C#)交互
1.首先从Github-Protobuf下载代码,本文下载的版本号是3.1.0. 2.仔细查看各个README,有相关的资源下载和编译说明. 3.在一个方便的地方创建一个Install类型的文件夹,放 ...