吾爱破解 - 52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 1989|回复: 5
收起左侧

[Python 转载] ~~爬取北交所新股申购信息~~

  [复制链接]
老冉 发表于 2021-12-22 15:23
本帖最后由 老冉 于 2021-12-22 22:28 编辑

[Python] 纯文本查看 复制代码
import requests
import json
import time
import re
import pandas as pd


def bce_all():
    url = 'http://www.bse.cn/newShareController/infoResult.do?callback=jQuery331_' + str(int(time.time() * 1000))
    headers = {
        "Referer": "http: //www.bse.cn/newshare/listofissues.html",
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.45 Safari/537.36"
    }
    form = [
        ("statetypes[]", "0"),
        ("page", "0"),
        ("companyCode", ''),
        ("isNewThree", "1"),
        ("sortfield", "purchaseDate"),
        ("sorttype", "desc"),
        ("keyword", ''),
        ("needFields[]", "id"),
        ("needFields[]", "stockCode"),
        ("needFields[]", "stockName"),
        ("needFields[]", "initialIssueAmount"),
        ("needFields[]", "enquiryType"),
        ("needFields[]", "issuePrice"),
        ("needFields[]", "peRatio"),
        ("needFields[]", "purchaseDate"),
        ("needFields[]", "issueResultDate"),
        ("needFields[]", "enterPremiumDate"),
    ]
    response = requests.post(url, headers=headers, data=form)
    a = re.findall(r'\[{.*}\]', response.text)
    if a:
        b = json.loads(a[0])[0]['listInfo']['content']
        data = []
        for x in b:
            if x['enterPremiumDate']:
                data.append({"代码": x['stockCode'],
                             "简称": x['stockName'],
                             "发行量": x['initialIssueAmount'],
                             "发行价格": x['issuePrice'],
                             "市盈率": x['peRatio'],
                             "申购日": time.strftime("%Y-%m-%d", time.localtime(x['purchaseDate']['time'] / 1000)),
                             "上市日": time.strftime("%Y-%m-%d", time.localtime(x['enterPremiumDate']['time'] / 1000)),
                            })
            else:
                data.append({"代码": x['stockCode'],
                             "简称": x['stockName'],
                             "发行量": x['initialIssueAmount'],
                             "发行价格": x['issuePrice'],
                             "市盈率": x['peRatio'],
                             "申购日": time.strftime("%Y-%m-%d", time.localtime(x['purchaseDate']['time'] / 1000)),
                             "上市日": '  ------  ',
                             })
    else:
        print('bad')
    return data


if __name__ == '__main__':
    pd.set_option('display.unicode.ambiguous_as_wide', True)
    pd.set_option('display.unicode.east_asian_width', True)
    data = pd.DataFrame(bce_all()[:10])
    

data
     代码      简称    发行量  发行价格  市盈率      申购日      上市日
0  871245  威博液压   8478261      9.68   18.59  2021-12-22    ------  
1  836720  吉冈精密  21030000     10.50   21.67  2021-11-03  2021-11-24
2  836260  中寰股份   8500000     13.45   16.00  2021-11-01  2021-11-15
3  871981  晶赛科技  11878300     18.32   28.41  2021-10-26  2021-11-15
4  831832  科达自控  18000000     13.00   45.34  2021-10-26  2021-11-15
5  833454  同心传动  25000000      3.95   14.90  2021-10-18  2021-11-15
6  870436  大地电气  18000000      8.68   13.21  2021-10-18  2021-11-15
7  832171  志晟信息  14530435      6.80   10.93  2021-10-15  2021-11-15
8  833873  中设咨询  33380000      4.50   27.28  2021-10-15  2021-11-15
9  832089  禾昌聚合  20000000     10.00   16.39  2021-10-11  2021-11-09

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

乐行中国 发表于 2021-12-22 16:40
哈哈哈 厉害
py学徒 发表于 2021-12-23 20:35
shanhu5235 发表于 2021-12-24 13:27
qinrongling 发表于 2022-2-1 13:37
楼主好人,支持楼主分享
466701 发表于 2022-2-10 14:07
大哥,能不能弄个爬股票的净利润,资产历年的资料,做成的财报分析PPT
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

返回列表

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-11-25 09:48

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表