Maison  >  Article  >  développement back-end  >  Apprenez à utiliser Python pour obtenir rapidement des actions du secteur industriel afin de faciliter l'investissement de valeur !

Apprenez à utiliser Python pour obtenir rapidement des actions du secteur industriel afin de faciliter l'investissement de valeur !

王林
王林avant
2023-04-14 10:49:021769parcourir

Apprenez à utiliser Python pour obtenir rapidement des actions du secteur industriel afin de faciliter l'investissement de valeur !

1. Secteurs industriels

Il existe une grande différence de définition entre les secteurs industriels et les valeurs conceptuelles.

De manière générale, les secteurs conceptuels sont plus risqués. Ils sont médiatisés à court terme en fonction d'une certaine actualité et sont très instables, donc les risques sont plus grands.

Les secteurs industriels sont classés selon les secteurs boursiers et ont tendance à se concentrer sur le long. terme et ont une plus grande stabilité.

En termes d'investissement réel, À court terme, vous pouvez sélectionner des actions parmi les actions conceptuelles en fonction des « points chauds du marché ». À moyen et long terme, il est recommandé de sélectionner des actions en fonction des « secteurs industriels » pour investir. .

2. Parcourez la liste des secteurs et actions pertinents

Cible cible :

aHR0cDovL3N1bW1hcnkuanJqLmNvbS5jbi9oeWJrLw==

Apprenez à utiliser Python pour obtenir rapidement des actions du secteur industriel afin de faciliter l'investissement de valeur !

2-1 Liste des secteurs

Tout d'abord, nous utilisons le plug "Toggle JavaScript"- in pour découvrir le contenu de la page Les données du secteur industriel proviennent des résultats de requête suivants

https://www.php.cn/link/6e839dd93911f945cd02c9b15da23db0

Apprenez à utiliser Python pour obtenir rapidement des actions du secteur industriel afin de faciliter l'investissement de valeur !

où les paramètres sont p et _dc sont des paramètres variables, p représente le numéro de page (à partir de 1), _dc représente l'horodatage à 13 chiffres et les autres paramètres de requête sont du contenu fixe

Ensuite, nous écrivons du code pour obtenir les données de réponse et utilisons des expressions régulières pour correspondre aux données de la liste de l'industrie

...
self.ps_url = 'http://**/?q=cn|bk|17&n=hqa&c=l&o=pl,d&p={}050&_dc={}'
....
    def __get_timestramp(self):
        """
        获取13位的时间戳
        :return:
        """
        return int(round(time.time() * 1000))
...
    def get_plates_list(self, plate_keyword):
        """
        获取所有板块
        :return:
        """
        plates = []

        index = 0
        while True:
            url = self.ps_url.format(index + 1, self.__get_timestramp())
            # 解析数据
            resp = self.session.get(url, headers=self.headers).text
            match = re.compile(r'HqData:(.*?)};', re.S)
            result = json.loads(re.findall(match, resp)[0].strip().replace("n", ""))
            if not result:
                break

            # 根据关键字,过滤有效板块
            temp_plate_list = [item for item in result if plate_keyword in item[2]]
            index += 1

            for item in temp_plate_list:
                print(item)

                plates.append({
                    "name": item[2],
                    "plate_path": item[1],
                    "up_or_down": str(item[10]) + "%",
                    "top_stock": item[-6]
                })
        return plates
...

Enfin, les secteurs sont filtrés en fonction des mots-clés et réassemblés dans une liste à travers le nom du secteur, le chemin du secteur PATH, la hausse et la baisse du secteur et le nom du titre avec le plus grand contribution

Remarque : Grâce à la page d'analyse, on constate que le chemin du secteur PATH peut être assemblé L'URL de la page de liste des stocks du secteur industriel

Par exemple, si le chemin du secteur industriel PATH est 400128925, alors L'URL de la page de liste des stocks du secteur industriel est

https://www.php.cn/link/0cb5ebb1b34ec343dfe135db69 1e4a85

2-2 Liste des stocks de l'industrie

L'exploration de la liste des stocks de l'industrie est la même comme la logique d'affichage des données à l'étape précédente. Les données de la liste de stocks proviennent également des résultats de la requête suivante

Parmi eux, bk correspond au PATH du secteur industriel, p représente le numéro de page et _dc représente l'horodatage à 13 chiffres

...
# 个股
self.stock_url = 'https://www.php.cn/link/f9995e4c8a1e54123c64427a572d7917'
....
    def get_stock_list(self, plate_path):
        """
        获取某一个板块下所有的个股信息
        包含:股票名称、最新价格、涨跌幅、市盈率
        :param plate_info:
        :return:
        """
        index = 0
        stocks = []
        while True:
            url = self.stock_url.format(plate_path, index + 1, self.__get_timestramp())
            resp = self.session.get(url, headers=self.headers).text
            match = re.compile(r'HqData:(.*?)};', re.S)
            result = json.loads(re.findall(match, resp)[0].strip().replace("n", ""))
            if not result:
                break
            index += 1

            for item in result:
                if item[-1] < 0:
                    continue
                stocks.append({
                    "stock_name": item[2],
                    "pe": item[-1],
                    "price": item[8],
                    "up_or_down": str(item[12]) + "%"
                })

        # 按pe降序排列
        stocks.sort(key=lambda x: x["pe"])

        return stocks
Après avoir fait correspondre les résultats de la réponse via des expressions régulières, obtenez le nom de l'action individuelle, le ratio cours-bénéfice PE, le prix, augmenter et diminuer 4 données clés

Enfin, triez la liste des actions individuelles par ordre croissant par PE et revenez directement

3 Servitisation

Bien sûr, nous pouvons gérer cette partie de la logique pour une utilisation frontale Dans l'ordre. pour améliorer l'expérience utilisateur

Par exemple, en utilisant

FastAPI

, vous pouvez créer rapidement deux services : obtenir une liste de secteurs industriels basée sur des mots-clés et obtenir une liste d'actions individuelles basée sur des chemins sectoriels

<span style="color: rgb(215, 58, 73); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">from</span> <span style="color: rgb(89, 89, 89); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">pydantic</span> <span style="color: rgb(215, 58, 73); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">import</span> <span style="color: rgb(89, 89, 89); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">BaseModel</span><br><br><span style="color: rgb(106, 115, 125); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);"># 板块</span><br><span style="color: rgb(215, 58, 73); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">class</span> <span style="color: rgb(0, 92, 197); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">Plate</span>(<span style="color: rgb(89, 89, 89); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">BaseModel</span>):<br>    <span style="color: rgb(89, 89, 89); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">content</span>: <span style="color: rgb(111, 66, 193); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">str</span>  <span style="color: rgb(106, 115, 125); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);"># 关键字</span><br><br><br><span style="color: rgb(106, 115, 125); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);"># 板块下的个股</span><br><span style="color: rgb(215, 58, 73); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">class</span> <span style="color: rgb(0, 92, 197); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">PlateStock</span>(<span style="color: rgb(89, 89, 89); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">BaseModel</span>):<br>    <span style="color: rgb(89, 89, 89); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">plate_path</span>: <span style="color: rgb(111, 66, 193); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">str</span>  <span style="color: rgb(106, 115, 125); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);"># 板块路径</span><br><br><span style="color: rgb(106, 115, 125); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">#===========================================================</span><br><span style="color: rgb(215, 58, 73); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">...</span><br><br><span style="color: rgb(106, 115, 125); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);"># 获取板块列表</span><br><span style="color: rgb(31, 127, 154); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">@</span><span style="color: rgb(31, 127, 154); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">app</span>.<span style="color: rgb(0, 92, 197); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">post</span>(<span style="color: rgb(102, 153, 0); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">"/xag/plate_list"</span>)<br><span style="color: rgb(215, 58, 73); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">async</span> <span style="color: rgb(215, 58, 73); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">def</span> <span style="color: rgb(0, 92, 197); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">get_plate_list</span>(<span style="color: rgb(89, 89, 89); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">plate</span>: <span style="color: rgb(89, 89, 89); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">Plate</span>):<br>    <span style="color: rgb(89, 89, 89); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">pstock</span> <span style="color: rgb(215, 58, 73); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">=</span> <span style="color: rgb(89, 89, 89); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">PStock</span>()<br>    <span style="color: rgb(215, 58, 73); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">try</span>:<br>        <span style="color: rgb(89, 89, 89); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">result</span> <span style="color: rgb(215, 58, 73); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">=</span> <span style="color: rgb(89, 89, 89); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">pstock</span>.<span style="color: rgb(0, 92, 197); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">get_plates_list</span>(<span style="color: rgb(89, 89, 89); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">plate</span>.<span style="color: rgb(0, 92, 197); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">content</span>)<br>        <span style="color: rgb(215, 58, 73); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">return</span> <span style="color: rgb(89, 89, 89); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">success</span>(<span style="color: rgb(89, 89, 89); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">data</span><span style="color: rgb(215, 58, 73); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">=</span><span style="color: rgb(89, 89, 89); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">result</span>, <span style="color: rgb(89, 89, 89); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">message</span><span style="color: rgb(215, 58, 73); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">=</span><span style="color: rgb(102, 153, 0); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">"查询成功!"</span>)<br>    <span style="color: rgb(215, 58, 73); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">except</span> <span style="color: rgb(89, 89, 89); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">Exception</span> <span style="color: rgb(215, 58, 73); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">as</span> <span style="color: rgb(89, 89, 89); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">e</span>:<br>        <span style="color: rgb(215, 58, 73); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">return</span> <span style="color: rgb(89, 89, 89); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">fail</span>()<br>    <span style="color: rgb(215, 58, 73); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">finally</span>:<br>        <span style="color: rgb(89, 89, 89); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">pstock</span>.<span style="color: rgb(0, 92, 197); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">teardown</span>()<br><br><br><span style="color: rgb(106, 115, 125); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);"># 获取某一个板块下的所有股票列表</span><br><span style="color: rgb(31, 127, 154); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">@</span><span style="color: rgb(31, 127, 154); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">app</span>.<span style="color: rgb(0, 92, 197); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">post</span>(<span style="color: rgb(102, 153, 0); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">"/xag/plate_stock_list"</span>)<br><span style="color: rgb(215, 58, 73); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">async</span> <span style="color: rgb(215, 58, 73); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">def</span> <span style="color: rgb(0, 92, 197); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">get_plate_list</span>(<span style="color: rgb(89, 89, 89); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">plateStock</span>: <span style="color: rgb(89, 89, 89); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">PlateStock</span>):<br>    <span style="color: rgb(89, 89, 89); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">pstock</span> <span style="color: rgb(215, 58, 73); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">=</span> <span style="color: rgb(89, 89, 89); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">PStock</span>()<br>    <span style="color: rgb(215, 58, 73); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">try</span>:<br>        <span style="color: rgb(89, 89, 89); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">result</span> <span style="color: rgb(215, 58, 73); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">=</span> <span style="color: rgb(89, 89, 89); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">pstock</span>.<span style="color: rgb(0, 92, 197); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">get_stock_list</span>(<span style="color: rgb(89, 89, 89); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">plateStock</span>.<span style="color: rgb(0, 92, 197); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">plate_path</span>)<br>        <span style="color: rgb(215, 58, 73); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">return</span> <span style="color: rgb(89, 89, 89); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">success</span>(<span style="color: rgb(89, 89, 89); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">data</span><span style="color: rgb(215, 58, 73); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">=</span><span style="color: rgb(89, 89, 89); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">result</span>, <span style="color: rgb(89, 89, 89); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">message</span><span style="color: rgb(215, 58, 73); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">=</span><span style="color: rgb(102, 153, 0); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">"查询成功!"</span>)<br>    <span style="color: rgb(215, 58, 73); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">except</span> <span style="color: rgb(89, 89, 89); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">Exception</span> <span style="color: rgb(215, 58, 73); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">as</span> <span style="color: rgb(89, 89, 89); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">e</span>:<br>        <span style="color: rgb(215, 58, 73); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">return</span> <span style="color: rgb(89, 89, 89); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">fail</span>()<br>    <span style="color: rgb(215, 58, 73); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">finally</span>:<br>        <span style="color: rgb(89, 89, 89); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">pstock</span>.<span style="color: rgb(0, 92, 197); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">teardown</span>()<br><span style="color: rgb(215, 58, 73); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">...</span><br><br>

Prenez Uniapp comme un exemple pour le front-end, utilisez uni- Le composant table affiche la liste des secteurs industriels et la liste des stocks individuels

Une partie du code est la suivante :

//个股列表 platestock.vue
...
<view >
                <uni-forms ref="baseForm" :modelValue="baseFormData" :rules="rules">
                    <uni-forms-item label="关键字" required name="content">
                        <uni-easyinput v-model="baseFormData.content" placeholder="板块关键字" />
                    </uni-forms-item>
                </uni-forms>
                <button type="primary" @click="submit('baseForm')">提交</button>

                <!-- 结果区域 -->
                <view  v-show="result.length>0">
                    <uni-table ref="table" border stripe emptyText="暂无数据">
                        <uni-tr >
                            <uni-th align="center"  width="100%">板块</uni-th>
                            <uni-th align="center"  width="100%">涨跌幅</uni-th>
                            <uni-th align="center"  width="100%">强势股</uni-th>
                        </uni-tr>
                        <uni-tr  v-for="(item, index) in result" :key="index" @row-click="rowclick(item)">
                            <uni-td  align="center">{{ item.name }}</uni-td>
                            <uni-td align="center" >{{ item.up_or_down }}</uni-td>
                            <uni-td align="center" >{{ item.top_stock }}</uni-td>
                        </uni-tr>
                    </uni-table>
                </view>
            </view>
...
methods: {
            //表单提交数据
            submit(ref) {
                this.$refs[ref].validate().then(res => {
                    this.$http('xag/plate_list', this.baseFormData, {
                        hideLoading: false,
                        hideMsg: false,
                        method: 'POST'
                    }).then(res => {
                        console.log("内容:", res.data)
                        if (res.data && res.data.length > 0) {
                            this.$tip.success("查询成功!")
                            this.result = res.data
                        } else {
                            this.$tip.success("查询结果为空,请换一个关键字查询!")
                        }
                    }).catch(err => {
                        console.log("产生异常,异常信息:", err)
                    })

                }).catch(err => {
                    console.log('err', err);
                })
            }
...

Après le déploiement final du projet, vous pouvez sélectionner les stocks appropriés pour investissement basé sur les noms des secteurs sur la page d'accueil

4. Résumé Jetons un coup d'oeilApprenez à utiliser Python pour obtenir rapidement des actions du secteur industriel afin de faciliter l'investissement de valeur !

Étant donné que les secteurs industriels sont plus adaptés à l'investissement à moyen et long terme, il nous suffit de filtrer un secteur en fonction d'un certain mot-clé, puis dans la liste des actions du secteur, nous pouvons voir de manière très intuitive les actions avec des ratios cours/bénéfice plus faibles pour l'investissement.

Ce qui précède est le contenu détaillé de. pour plus d'informations, suivez d'autres articles connexes sur le site Web de PHP en chinois!

Déclaration:
Cet article est reproduit dans:. en cas de violation, veuillez contacter admin@php.cn Supprimer