Security_Code/Spider/BuTian.NET/CODE/补天爬虫/补天直接获取网址/run.py

60 lines
15 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# -*- coding:utf-8 -*-
#__author__:langzi
#__blog__:www.langzi.fun
import requests
import re
import time
headers = {
'Accept': 'application/json, text/javascript, */*; q=0.01',
'Accept-Encoding': 'gzip, deflate, br',
'Accept-Language': 'zh,zh-CN;q=0.9,en-US;q=0.8,en;q=0.7',
'Connection': 'keep-alive',
'Content-Length': '16',
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
'Cookie':'改成你自己的',
'Host': 'www.butian.net',
'Origin': 'https://www.butian.net',
'Referer': 'ttps://www.butian.net/Loo/submit',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36',
'X-Requested-With': 'XMLHttpRequest'
}
def parse_data(jsons):
data1 = jsons['data']
print('总数量为:{}'.format(len(data1)))
for i in data1:
#print(i['company'])
if i['company'].count('.')>0:
with open('srcname技巧寻找.txt', 'a+', encoding='utf-8')as a:
a.write(i['company'] + '\n')
else:
with open('企业名称技巧寻找.txt','a+',encoding='utf-8')as a:
a.write(i['company']+'\n')
import random
keywords = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, '', '', '', '', '', '', '', '', '', '', '鹿', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '绿', 'X', '', '', 'u', '', '', '', '', '', '', '', '', '', '', '耀', '', '', '', '', '', '', '', '', '', '', '', '使', '', '', '', '', '', '', '', '', '', '', '', '·', '', '', '', '', '', '(', '', '', '', '', '', '', '', 'p', '', '', '', '', '重庆', '', '', '', '', 'J', '', '', '', '股份', '', '', '', '', '委员会', '江苏', 'G', '', '', '', '', '', '', '', '', '', '|', '', '', '', '福建', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '陕西', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ' ', '', '', '', '', '', '', '', '', '', '', '', '', '', '姿', '', '', '', '', 'h', '', '3', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '\n', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '.', '', '', '', '', '', '', '', '', '', '', '网站', '', '', '', '', '湖北', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '云南', '', '', '', '', '', '', '', '2', '', '海南', '', '', '甘肃', '', '', '', '', '', '', '河北', '', '', '浙江', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ':', '', '', '', '', '', '', '', '', '', '', 'i', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 'b', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '西藏', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 'W', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '6', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 'P', '', '', '5', '', '', '', '', '', '', '', '', '', '', '', '', 'U', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '平台', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '保障局', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '有限公司', '', '', '', '', '', '', '', '', '', '香港', '', 'L', '', '', '', '', '', '', 'B', '', '', '', '', '', '', '', '', '', '', '宿', '', '', '', '', '', '', '山西', '', '', '', '', '7', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '河南', '', '', '', '青海', '', '', '', '', '', '', '', '寿', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '安徽', '', '', '', '', '', '', '', '', '', 'e', '', '', '', 't', '', '', '', '', '', '', '社会保障', '', '', '', '', '', '', '', '大学', '', '', '', '', '学院', '', '', '', '', '', '', '', '', '', '', '西', '', '', '', '', '', '', '', '', '', '', '人力资源', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '新疆', '', '', '', '屿', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ')', '', '宁夏', '', '', '职业', '上海', 'y', '', '', '', '', '', '', '', '', '', 'N', '', '', '', '', 'r', '', 'a', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '人民政府', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '中国', '', '', '管理局', '', '', '', '', 's', '', '', '', '_', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '0', '', 'V', '', '', '', '饿', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '天津', '', '', '', '', '', '', '', '', '', '', '', '', '科技', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '江西', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 'm', '', '', '', '', '', '', '', '', '', '', '', '', 'x', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 'I', '社会', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 'D', '山东', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '-', '', '', '', '', '', '访', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '4', '', 'E', '', '', '', '', '', '人才网', '', '', '', 'j', '', '', '', '', '', '', '', 'l', '', '', '', '', '', '', '', '', '', '', '', '', '线', '贵州', '', '', '', '', 'F', '内蒙古', 'C', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 'M', '', '', '', '', '', '', '便', '', '齿', '', '', '', '', '广西', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 'O', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 'Z', '', '', '', '', '', '', '', '', '', '', '', '澳门', '', '', '', '', '湖南', 'd', '', 'v', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '教育', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 'f', 'k', '', '', '', '', '', '怀', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '广', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '鸿', '', '', '', '', '', '', '', '', '', '', '', '', '', 'T', '', '', '', '', '', '', '', '', '吉林', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 'q', '', '', '/', '', '卫生', '', '', '', '', '', '', '', '', '', '', '', '', '', '广东', '', '', '', '', '', '', '', '', '', '台湾', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 'R', '', '财产保险', '服务网', '', '', '', '', '', '', '', '', '', '', 'z', '', '', '', '', '技术', '', '', '', '', '', '', '黑龙江', '', '', '', '', '', '', '', '', '', '', '', '', 'H', '', '', '', '', '', '', '', '', '', '', '', '', '网络科技', '', 'K', '8', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '四川', '', '', '', '', '', '', '', '', '', '1', '', '', '', '', '', '', 'c', '', '', '', '', '', 'w', 'Y', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 'o', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '9', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '北京', '', '', '', '', '', '', '', '', '', '', '', '', '', 'n', '', '', '', '', '', '', '', '', '', '', '集团', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '亿', '', '', '', '', '', '', '', '', '', '', '', '', 'g', '', '', '', '辽宁', '', '', '信息网', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 'S', '', '', '', '', 'A', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '']
def run(keyword):
print('当前关键词为:{}'.format(keyword))
time.sleep(random.randint(1,5))
url = 'https://www.butian.net/Home/Loo/getCompanyList'
data = {
'token': '6da620c95601c38a988617b7f811cc487e5c7150',
'company_name': keyword
}
r = requests.post(url=url, data=data,headers=headers)
# print(r.json())
# import time
# time.sleep(50)
try:
parse_data(r.json())
except Exception as e:
print(e)
time.sleep(20)
for k in keywords:
run(k)