我试图从此网址获取JSON响应:
import time
from time import mktime
import requests
import json
header = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.162 Safari/537.36'}
payload = {
"jobCity":"null",
"jobSkill":"null",
"pageNumber":1,
"userText":"",
"jobTitleOrder":"null",
"jobCityOrder":"null",
"jobFunctionOrder":"null",
"jobExperienceOrder":"null",
"applyByOrder":"null",
"regular":"true",
"walkin":"true"
}
response = requests.post(url="https://ibegin.tcs.com/iBegin/api/v1/jobs/searchJ?at=",headers=header,json=payload,params=str(long((time.time()) * 1000)))
json_obj = json.loads(response.text)
print json_obj
但打印结果为空:
{u'message': u'Ok.', u'data': {u'jobs': [], u'totalJobs': 0}, u'result': u'Y'}
而不是:
{"message":"Ok.","result":"Y","data":{"totalJobs":50,"jobs":[{"id":"120315J","jobTitle":"Python Developer ","location":"Singapore","functionName":"TECHNOLOGY","experience":"1-10","applyByDate":"27-APR-2018 11:59:59 PM","skills":"Python","walkin":"J","url":null},{"id":"120281J","jobTitle":"Java Developer","location":"Singapore","functionName":"TECHNOLOGY","experience":"3-8","applyByDate":"21-MAY-2018 11:59:59 PM","skills":"J2EE , Java","walkin":"J","url":null},{"id":"120280J","jobTitle":"Aws Tech Lead","location":"Singapore","functionName":"TECHNOLOGY","experience":"8-12","applyByDate":"30-APR-2018 11:59:59 PM","skills":"AWS redshift , Cloud AWS/Amazon","walkin":"J","url":null},{"id":"120277J","jobTitle":"Technical Support Executive","location":"Singapore","functionName":"IT INFRASTRUCTURE SERVICES","experience":"0-3","applyByDate":"30-APR-2018 11:59:59 PM","skills":"IT Infrastructure ","walkin":"J","url":null},{"id":"120276J","jobTitle":"Java Developer","location":"Singapore","functionName":"TECHNOLOGY","experience":"3-6","applyByDate":"30-APR-2018 11:59:59 PM","skills":"EJB , Weblogic Server , Java , JMS , Eclipse","walkin":"J","url":null},{"id":"120273J","jobTitle":"Aws Technical Lead","location":"Singapore","functionName":"TECHNOLOGY","experience":"5-10","applyByDate":"23-APR-2018 11:59:59 PM","skills":"AWS , AWS Deployment","walkin":"J","url":null},{"id":"120209J","jobTitle":"Sap Fico Consultant","location":"Singapore","functionName":"TECHNOLOGY","experience":"4-10","applyByDate":"18-APR-2018 11:59:59 PM","skills":"SAP FICO","walkin":"J","url":null},{"id":"120094J","jobTitle":"Apo Consultant","location":"Singapore","functionName":"TECHNOLOGY","experience":"8-10","applyByDate":"10-APR-2018 11:59:59 PM","skills":"SAP APO SNP , SAP APO","walkin":"J","url":null},{"id":"119352J","jobTitle":"Software Engineer (Java/J2ee)","location":"Singapore","functionName":"TECHNOLOGY","experience":"3-10","applyByDate":"31-MAR-2018 11:59:59 PM","skills":"J2EE , Angular JS , Java","walkin":"J","url":null},{"id":"119234J","jobTitle":"Ui Developer","location":"Singapore","functionName":"TECHNOLOGY","experience":"4-8","applyByDate":"01-MAY-2018 11:59:59 PM","skills":"Javascript , Node JS , TypeScript , BackboneJS , Angular JS , HTML","walkin":"J","url":null}]}}
还有什么需要添加到请求声明中吗?
答案 0 :(得分:0)
运行代码之后,代码似乎没有任何问题:您发布了一个请求的并且没有(作业)结果,没有任何问题。也许tweeking用于POST请求的JSON参数将产生一些结果