**如下:
import requests
from bs4 import beautifulsoup
import time
keyword = input('請輸入要查詢的公司名稱:')
# url = ''%(kewword)
headers =
page = 1
while true:
try:
url = '' % (keyword,page)
response = requests.get(url=url,headers = headers)
# text = response.content.decode('utf-8')
text = response.json()
# print(text)
# with open('xinyong.html','w',encoding='utf-8') as fp:
# fp.write(text)
data = text['data']['results']
# print(data)
if data:
for i in data:
headers =
name = i['name']
encrystr = i['encrystr'].split('\n')[0]
# # 資訊概覽
link = ''+encrystr
response1 = requests.get(url =link,headers= headers)
text1 = response1.json()
# print(text1)
print('公司名稱:',text1['result']['entname'])
print('工商註冊號:',text1['result']['regno'])
print('法人資訊:',text1['result']['legalperson'])
print('成立日期:',text1['result']['esdate'])
print('企業型別:',text1['result']['enttype'])
print('登記機關:',text1['result']['regorg'])
with open('xinyong.txt','a',encoding='utf-8') as fp:
fp.write('公司名稱:'+text1['result']['entname']+'工商註冊號:'+text1['result']['regno']+'法人資訊:'+text1['result']['legalperson']+'成立日期:'+text1['result']['esdate']+'企業型別:'+text1['result']['enttype']+'登記機關:'+text1['result']['regorg']+'\n')
# # 行政許可
# link1 =''%(name)
# response2 = requests.get(url=link1,headers=headers)
# text2 = response2.json()
# print(text2)
# # print('行政許可:',text2['result']['results'])
# # 行政處罰
# link3 = ''%(name)
# response3 = requests.get(url=link3, headers=headers)
# text3 = response3.json()
# # print(text3)
# # print('行政處罰:',text3['result']['result'])
## # 守信紅名單
# link4 = ''%(encrystr)
# response4 = requests.get(url=link,headers =headers)
# text4 = response4.json()
# # print(text4)
# # print('守信紅名單',text4['result'])##
# # 重點關注名單
# link5 = ''%(encrystr)
# response5 = requests.get(url = link5,headers =headers)
# text5 = response5.json()
# # print(text5)
# # print('重點關注名單',text5['result'])
## # 黑名單
# link6 =''%(encrystr)
# response6 = requests.get(url=link6,headers=headers)
# text6 = response6.json()
# print(text6)
# print('黑名單',text6['result'])
# time.sleep(1)
page+=1
else:
print('沒有資料了')
break
except exception as e:
print('爬取失敗',e)
爬取中國天氣
import requests from bs4 import beautifulsoup def parser page url headers response requests.get url,headers headers text response.content.decode utf 8...
中國災害預警爬取解析
有獲取災害資訊提醒的需求,但是發現並沒有開發的api 已有的api都需要付錢。天氣預報api,可以看知乎的這邊文章。網上的天氣 api 哪乙個更加可靠?裡面的普通的天氣預報部分免費,但是災害預警的api都是需要收費的。於是自己去摸索了。最後通過發f12發現了中國天氣網中可用的請求 順便寫了下解析使用...
豆瓣影評爬取 中國機長
10月大火的中國機長相信大家都看過了吧 悄悄的說,我還有二刷?超級超級超級超級喜歡袁泉姐姐,溫柔又堅定,真誠又勇敢!import requests from bs4 import beautifulsoup import time import pandas as pd import os def ...