In [2]:
from urllib.parse import quote_plus
import requests
from spider.consts import LAGOU
from spider.lagou import http_headers

In [66]:
headers = http_headers()
headers.update({
    'Origin': 'https://www.lagou.com',
    'Referer': 'https://www.lagou.com/jobs/list_php?city=%E5%85%A8%E5%9B%BD&cl=false&fromSearch=true&labelWords=&suginput=',
    'X-Anit-Forge-Code': '0',
    'X-Anit-Forge-Token': 'None',
    'X-Requested-With': 'XMLHttpRequest'
})
r = requests.post(LAGOU.JOB_JSON_URL, headers=headers, data={'first': 'false', 'pn': '314', 'kd': 'php'})

In [67]:
r.status_code


Out[67]:
200

In [68]:
import json

In [69]:
obj = json.loads(r.text)

In [70]:
obj['content']['positionResult']


Out[70]:
{'hotLabels': None,
 'locationInfo': {'businessZone': None,
  'city': None,
  'district': None,
  'locationCode': None,
  'queryByGisCode': False},
 'queryAnalysisInfo': {'companyName': None,
  'industryName': None,
  'positionName': 'php',
  'usefulCompany': False},
 'result': [],
 'resultSize': 0,
 'strategyProperty': {'id': 0, 'name': 'dm-csearch-useUserInterest'},
 'totalCount': 4688}

In [ ]: