#coding=utf-8
import requests
from pymongo import MongoClient
#数据库建立
c=MongoClient(host='127.0.0.1',port=27017)
db=c['zhilian']
collection=db['zhilianhtml']
def zhilian(company,page):
for i in xrange(1,page):
#京东商城 北京
url="sou.zhaopin/jobs/searchresult.ashx?jl=%E5%8C%97%E4%BA%AC&kw=company=2&p=i"
header={
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36'
}
res=requests.get(url=url,headers=header)
#存入数据库中
collection.insert({'charles':res.content})
if __name__=='__main__':
company=raw_input('请输入您要查询的二手游戏账号买号平台:')
page=int(raw_input('请输入您要查找的页数:'))
if page<1:
print '输入错误!!!'
else:
zhilian(company,page)