Skip to content

Instantly share code, notes, and snippets.

@Everfighting
Created August 17, 2022 02:45
Show Gist options
  • Save Everfighting/7cc3a1f9fbaa8b9be645e7f4370765dd to your computer and use it in GitHub Desktop.
Save Everfighting/7cc3a1f9fbaa8b9be645e7f4370765dd to your computer and use it in GitHub Desktop.
import requests
import pandas
import copy
# 根据公司名或者app_code查询id
url = "http://121.5.100.192:7006/api/user_app/get_page"
res = requests.post(url=url, json={
"page_size": 1000,
"page_num": 1,
"like_name": ""
}).json()["data"]
df = pandas.DataFrame(res)
df_2 = pandas.DataFrame(df.res_list.apply(lambda x: {**x}).tolist())
df_2.company_name = df_2.company_name.apply(lambda x: str(x))
result = copy.deepcopy(df_2)[["app_code", "company_name", "id"]]
company = input("请输入公司名")
if company:
result = result.loc[result.company_name.str.contains(company)]
print(result)
if result.empty:
result = copy.deepcopy(df_2)[["app_code", "company_name", "id"]]
app_code = input("请输入app_code")
if app_code:
result = result.loc[result.app_code.str.contains(app_code)]
print(result)
if result.id.count() == 1:
pk = result.iloc[0].id
print(df_2.loc[df_2.id == pk].iloc[0])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment