zoukankan      html  css  js  c++  java
  • 用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()))
  • 相关阅读:
    Swift--集合类型 数组 字典 集合
    Swift--基础(一)基本类型 符号 字符串(不熟的地方)
    myFocus焦点图插件
    createjs基础
    111
    Foundation class diagram
    UIKit class diagram
    iOS Development
    What Is Cocoa?
    Cocoa 基本原理
  • 原文地址:https://www.cnblogs.com/liang715200/p/10151514.html
Copyright © 2011-2022 走看看