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

直接上代码:

  1. #-*-coding:utf-8-*-
  2. from common.contest import *
  3.  
  4. def spider():
  5.  
  6. headers = {
  7.  
  8. "Host":"zhaopin.baidu.com",
  9. "Connection":"keep-alive",
  10. "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",
  11. "Accept":"*/*",
  12. "Referer":"http://zhaopin.baidu.com/qz?query=%E7%88%AC%E8%99%AB%E5%B7%A5%E7%A8%8B%E5%B8%88",
  13. "Accept-Encoding":"gzip, deflate",
  14. "Accept-Language":"zh-CN,zh;q=0.8",
  15. "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",
  16.  
  17. }
  18.  
  19. url = 'http://zhaopin.baidu.com/api/qzasync'
  20. for page in range(0,11):
  21. print "正在爬取的页数是:",str(page)
  22. data = {
  23.  
  24. "query":"爬虫工程师",
  25. "city":"%E5%8C%97%E4%BA%AC",
  26. "pcmod":"",
  27. "pn":str(page),
  28. "rn":"",
  29. }
  30.  
  31. result = session.get(url=url,params=data,headers=headers).json()
  32. result = result['data']['disp_data']
  33. for ii in result:
  34.  
  35. try:
  36. ori_size = ii['ori_size']
  37. except:
  38. ori_size = ""
  39.  
  40. ori_city = ii['ori_city']
  41. ori_type = ii['ori_type']
  42. StdStl = ii['StdStl']
  43. sourcelink = ii['sourcelink']
  44. _version = ii['_version']
  45. haswapurl = ii['haswapurl']
  46. education = ii['education']
  47.  
  48. try:
  49. size = ii['size']
  50. except:
  51. size = ""
  52.  
  53. format_date = ii['format_date']
  54. detailidx = ii['detailidx']
  55. title = ii['title']
  56. ori_employertype = ii['ori_employertype']
  57. requirements = ii['requirements']
  58. company_id = ii['company_id']
  59. ori_salary = ii['ori_salary']
  60. source = ii['source']
  61. location = ii['location']
  62. provider = ii['provider']
  63. employertype = ii['employertype']
  64. lastmod = ii['lastmod']
  65. _update_time = ii['_update_time']
  66. ori_education = ii['ori_education']
  67.  
  68. try:
  69. companyaddress = ii['companyaddress']
  70. except:
  71. companyaddress = ""
  72.  
  73. company = ii['company']
  74. try:
  75. commonname = ii['commonname']
  76. except:
  77. commonname = ""
  78.  
  79. ori_welfare = ii['ori_welfare']
  80. ori_experience = ii['ori_experience']
  81.  
  82. ori_welfare = str(ori_welfare).decode('unicode_escape')
  83.  
  84. print "ori_salary",ori_salary
  85. print "ori_size",ori_size
  86. print "ori_city",ori_city
  87. print "ori_type",ori_type
  88. print "StdStl",StdStl
  89. print "sourcelink",sourcelink
  90. print "_version",_version
  91. print "haswapurl",haswapurl
  92. print "education",education
  93. print "id",id
  94. print "size",size
  95. print "format_date",format_date
  96. print "detailidx",detailidx
  97. print "title",title
  98. print "ori_employertype",ori_employertype
  99. print "requirements",requirements
  100. print "company_id",company_id
  101. print "ori_salary",ori_salary
  102. print "ori_salary",ori_salary
  103. print "source",source
  104. print "employertype",employertype
  105. print "location",location
  106. print "provider",provider
  107. print "employertype",employertype
  108. print "lastmod",lastmod
  109. print "_update_time",_update_time
  110. print "ori_education",ori_education
  111. print "companyaddress",companyaddress
  112. print "company",company
  113. print "commonname",commonname
  114. print "ori_welfare",ori_welfare
  115. print "ori_experience",ori_experience
  116.  
  117. time.sleep(5)
  118.  
  119. 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. Python调用Windows外部程序

    在Python中可以方便地使用os模块运行其他的脚本或者程序,这样就可以在脚本中直接使用其他脚本,或者程序提供的功能,而不必再次编写实现该功能的代码.为了更好地控制运行的进程,可以使用win32pro ...

  2. 元素高度、宽度获取 style currentStyle getComputedStyle getBoundingClientRect

    1.示例代码 (1)html <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> ...

  3. openerp 7.0邮件接收中文附件乱码问题解决办法

    openerp 7.0邮件接收中文附件乱码问题解决办法: 修改文件\addons\mail\mail_thread.py #1064 line插入代码: h=email.Header.Header(n ...

  4. Android玩转百度地图Sha1获取正确姿势?

    场景一 由于近期项目钟要用到定位功能因此肯定须要用到地图以及地位功能,相信大家也知道眼下国内比較出名的地图像百度.高德.腾讯等这些还是用到比較多的.于是思考了一下决定还是用百度,相信老司机们都知道的哈 ...

  5. V-rep学习笔记:Reflexxes Motion Library 1

    V-REP中集成了在线运动轨迹生成库Reflexxes Motion Library Type IV,目前Reflexxes公司已经被谷歌收购.(The Reflexxes Motion Librar ...

  6. 江南白衣整理和开发的java常用工具类

    江南白衣的公众号的介绍文章:http://mp.weixin.qq.com/s/6JUo1vmUa-7SuDH6yIxKeQ github的地址:https://github.com/springsi ...

  7. VirtualBox-5.0.16设置windows与ubuntu的共享文件夹

    操作环境:win7.VirtualBox-5.0.16.ubuntukylin-14.04.2-desktop-amd64 1.先下载安装VBoxGuestAdditions_5.0.17-10614 ...

  8. 转 CentOS下php安装mcrypt扩展

    (以下步骤均为本人实际操作,可能与你的安装方法有所区别,但我会尽量排除疑惑) 大致步骤(1)安装mcrypt,(2)安装php对mcrypt的扩展,(3)重启apache (1).确认你的linux没 ...

  9. [转载]JDBC/Spring/MyBatis性能比较

    原文地址:JDBC/Spring/MyBatis性能比较作者:tom_lt 测试目的: 比较JDBC,SpringJdbc和MyBatis的性能.   测试用例: 1. 查询:查询一张10000条数据 ...

  10. angularJS实现无刷新文件下载

    $scope.getExcel = function () { $http.post("/production/statistics/export", { storeId: $sc ...