今天闲的无聊,爬取了一个网站,百度百聘,仅供学习参考

直接上代码:

#-*-coding:utf-8-*-
from common.contest import * def spider(): headers = { "Host":"zhaopin.baidu.com",
"Connection":"keep-alive",
"User-Agent":"Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.91 Safari/537.36",
"Accept":"*/*",
"Referer":"http://zhaopin.baidu.com/qz?query=%E7%88%AC%E8%99%AB%E5%B7%A5%E7%A8%8B%E5%B8%88",
"Accept-Encoding":"gzip, deflate",
"Accept-Language":"zh-CN,zh;q=0.8",
"Cookie":"BAIDUID=F9ED0B117C16BC97A29D64DD28F4CBB9:FG=1; BIDUPSID=F9ED0B117C16BC97A29D64DD28F4CBB9; PSTM=1532340289; locale=zh;
      Hm_lvt_c676f95eebbd4fa8a59418f48090ac4d=1532922582; URLTITLESALARY=%20; Hm_lvt_80a630f2b5c230ad2a5d3f1356e18706=1532938867;
        Hm_lpvt_80a630f2b5c230ad2a5d3f1356e18706=1532941545; td_cookie=966486977", } url = 'http://zhaopin.baidu.com/api/qzasync'
for page in range(0,11):
print "正在爬取的页数是:",str(page)
data = { "query":"爬虫工程师",
"city":"%E5%8C%97%E4%BA%AC",
"pcmod":"",
"pn":str(page),
"rn":"",
} result = session.get(url=url,params=data,headers=headers).json()
result = result['data']['disp_data']
for ii in result: try:
ori_size = ii['ori_size']
except:
ori_size = "" ori_city = ii['ori_city']
ori_type = ii['ori_type']
StdStl = ii['StdStl']
sourcelink = ii['sourcelink']
_version = ii['_version']
haswapurl = ii['haswapurl']
education = ii['education'] try:
size = ii['size']
except:
size = "" format_date = ii['format_date']
detailidx = ii['detailidx']
title = ii['title']
ori_employertype = ii['ori_employertype']
requirements = ii['requirements']
company_id = ii['company_id']
ori_salary = ii['ori_salary']
source = ii['source']
location = ii['location']
provider = ii['provider']
employertype = ii['employertype']
lastmod = ii['lastmod']
_update_time = ii['_update_time']
ori_education = ii['ori_education'] try:
companyaddress = ii['companyaddress']
except:
companyaddress = "" company = ii['company']
try:
commonname = ii['commonname']
except:
commonname = "" ori_welfare = ii['ori_welfare']
ori_experience = ii['ori_experience'] ori_welfare = str(ori_welfare).decode('unicode_escape') print "ori_salary",ori_salary
print "ori_size",ori_size
print "ori_city",ori_city
print "ori_type",ori_type
print "StdStl",StdStl
print "sourcelink",sourcelink
print "_version",_version
print "haswapurl",haswapurl
print "education",education
print "id",id
print "size",size
print "format_date",format_date
print "detailidx",detailidx
print "title",title
print "ori_employertype",ori_employertype
print "requirements",requirements
print "company_id",company_id
print "ori_salary",ori_salary
print "ori_salary",ori_salary
print "source",source
print "employertype",employertype
print "location",location
print "provider",provider
print "employertype",employertype
print "lastmod",lastmod
print "_update_time",_update_time
print "ori_education",ori_education
print "companyaddress",companyaddress
print "company",company
print "commonname",commonname
print "ori_welfare",ori_welfare
print "ori_experience",ori_experience time.sleep(5) spider()

这个网址没有什么难度,只需要简单的请求一下请求接口就能得到数据,注意请求参数 city 需要  URL编码一下就可以,不会的同学请自行百度     URL编码  就可以了

Python 爬虫实例(15) 爬取 百度百聘(微信公众号)的更多相关文章

  1. Python爬虫实战之爬取百度贴吧帖子

    大家好,上次我们实验了爬取了糗事百科的段子,那么这次我们来尝试一下爬取百度贴吧的帖子.与上一篇不同的是,这次我们需要用到文件的相关操作. 本篇目标 对百度贴吧的任意帖子进行抓取 指定是否只抓取楼主发帖 ...

  2. Python爬虫实例:爬取B站《工作细胞》短评——异步加载信息的爬取

    很多网页的信息都是通过异步加载的,本文就举例讨论下此类网页的抓取. <工作细胞>最近比较火,bilibili 上目前的短评已经有17000多条. 先看分析下页面 右边 li 标签中的就是短 ...

  3. Python爬虫实例:爬取猫眼电影——破解字体反爬

    字体反爬 字体反爬也就是自定义字体反爬,通过调用自定义的字体文件来渲染网页中的文字,而网页中的文字不再是文字,而是相应的字体编码,通过复制或者简单的采集是无法采集到编码后的文字内容的. 现在貌似不少网 ...

  4. Python爬虫实例:爬取豆瓣Top250

    入门第一个爬虫一般都是爬这个,实在是太简单.用了 requests 和 bs4 库. 1.检查网页元素,提取所需要的信息并保存.这个用 bs4 就可以,前面的文章中已经有详细的用法阐述. 2.找到下一 ...

  5. [Python爬虫] 之十五:Selenium +phantomjs根据微信公众号抓取微信文章

    借助搜索微信搜索引擎进行抓取 抓取过程 1.首先在搜狗的微信搜索页面测试一下,这样能够让我们的思路更加清晰 在搜索引擎上使用微信公众号英文名进行“搜公众号”操作(因为公众号英文名是公众号唯一的,而中文 ...

  6. Python 爬虫练习: 爬取百度贴吧中的图片

    背景:最近开始看一些Python爬虫相关的知识,就在网上找了一些简单已与练习的一些爬虫脚本 实现功能:1,读取用户想要爬取的贴吧 2,读取用户先要爬取某个贴吧的页数范围 3,爬取每个贴吧中用户输入的页 ...

  7. 芝麻HTTP:Python爬虫实战之爬取百度贴吧帖子

    本篇目标 1.对百度贴吧的任意帖子进行抓取 2.指定是否只抓取楼主发帖内容 3.将抓取到的内容分析并保存到文件 1.URL格式的确定 首先,我们先观察一下百度贴吧的任意一个帖子. 比如:http:// ...

  8. 【python爬虫】 之 爬取百度首页

    刚开始学习爬虫,照着教程手打了一遍,还是蛮有成就感的.使用版本:python2.7 注意:python2的默认编码是ASCII编码而python3默认编码是utf-8 import urllib2 u ...

  9. Python爬虫教程-17-ajax爬取实例(豆瓣电影)

    Python爬虫教程-17-ajax爬取实例(豆瓣电影) ajax: 简单的说,就是一段js代码,通过这段代码,可以让页面发送异步的请求,或者向服务器发送一个东西,即和服务器进行交互 对于ajax: ...

随机推荐

  1. 树莓派通过GPIO控制步进电机

    一.接线方式与GPIO调用方法: 电源接入+5v和GND In1-4分别接GPIO1-4 正转时,GPIO1-4分次传入:[1,0,0,0],[sleep],[0,1,0,0],[sleep],[0, ...

  2. JAVA的堆于栈

    1. 栈(stack)与堆(heap):都是Java用来在Ram中存放数据的地方.与C++不同,Java自动管理栈和堆,程序员不能直接地设置栈或堆. 2. 栈的优势:存取速度比堆要快,仅次于直接位于C ...

  3. AndroidStudio 中查看获取MD5和SHA1值以及如何查看手机应用信息以及读取*.db数据库里面数据

    查看获取MD5和SHA1值具体操作方式链接 查看获取MD5和SHA1值实际操作命令CMD语句: C:\Users\Administrator>cd .android C:\Users\Admin ...

  4. Cocos开发小游戏如何实现微信排行榜

    当游戏开发进入尾声,要引入微信数据的时候,需要了解和微信相关的接口了. 关系数据链 开放数据域 相关接口如下: wx.getFriendCloudStorage() 获取当前用户也玩该小游戏的好友的用 ...

  5. The Builder pattern simulates named optional parameters(Java)

    the Builder pattern is a good choice when designing classes whose constructors or static factories w ...

  6. [转]文件后缀与Mime类型对照表

    //文档文件类型的 .ai application/postscript .eps application/postscript .exe application/octet-stream .doc ...

  7. 拦截导弹问题(NOIP1999)

    某国为了防御敌国的导弹袭击,开发出一种导弹拦截系统,但是这种拦截系统有一个缺陷:虽然它的第一发炮弹能够到达任意的高度, 但是以后每一发炮弹都不能高于前一发的高度.某天,雷达捕捉到敌国的导弹来袭,由于该 ...

  8. public static List SmaDataManager.getThreads(Context context)

    public static List<TxrjThreads> getThreads(Context context) 解析获取Threads列表之要点: 1. 得到带有fail信息的th ...

  9. EntityFramework 5.0 CodeFirst 教程02-删除和修改/架构改变异常的处理

    -----------------------------------------------------目录--------------------------------------------- ...

  10. Easyui入门视频教程 第02集--- ASP.NET MVC下 搭建 EasyUI环境

    Easyui入门视频教程 第02集--- ASP.NET MVC下 搭建 EasyUI环境 目录 ----------------------- Easyui入门视频教程 第09集---登录完善 图标 ...