• 用json获取拉钩网的信息


    class LaoGo(object):
    def __init__(self):
    self.url="http://www.lagou.com/lbs/getAllCitySearchLabels.json"
    self.headers={'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.67 Safari/537.36'}
    def get_down(self):
    response=requests.get(url=self.url,headers=self.headers)
    w=response.text
    return w
    def zhuan(self,w):
    w=la.get_down()
    qq=json.loads(w)
    return qq
    def write(self,qq):
    qq=la.zhuan(la.get_down())
    with open('city.json',mode='w',encoding='utf-8') as w:
    json.dump(qq,w,ensure_ascii=False)
    print("oooooooooooooooooooooooooooooooooooooooo")
    with open('city.json',mode='r',encoding='utf-8') as f:
    ww=json.load(f)
    print(ww)
    if __name__ == '__main__':
    la=LaoGo()
    # print(la.get_down())
    print("---------------------------------------------------------------------------------")
    print(la.zhuan(la.get_down()))
    print("wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww")
    la.write(la.zhuan(la.get_down()))
  • 相关阅读:
    Express框架学习总结
    Node.js学习心得
    清理svn.bat
    mysql sql语句大全
    SQL语句优化原则
    mysql数据库忘记密码时如何修改
    MySQL索引基础
    SQL语句优化技术分析
    mysql索引的类型和优缺点
    谷歌浏览器查询缓存视频图片
  • 原文地址:https://www.cnblogs.com/liang715200/p/10151514.html
Copyright © 2020-2023  润新知