Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请问下同花顺概念板块现在为什么拉不下来了? #105

Open
oneweek20169902 opened this issue Oct 16, 2024 · 9 comments
Open
Labels
question Further information is requested

Comments

@oneweek20169902
Copy link

如题

@1nchaos 1nchaos added the question Further information is requested label Oct 16, 2024
@1nchaos
Copy link
Owner

1nchaos commented Oct 16, 2024

朋友,麻烦提供一下代码截图什么的

@1nchaos
Copy link
Owner

1nchaos commented Oct 16, 2024

同时,概念有三种方式,都可以试试

@oneweek20169902
Copy link
Author

oneweek20169902 commented Oct 18, 2024

def concept_list():
"""获取概念板块下的成分股"""
concept = {}
exclude_list = ['融资融券', '深股通', 'MSCI概念', '标普道琼斯A股', '周期', '央企国企改革', '沪股通', '电子商务',
'云计算']
data = adata.stock.info.all_concept_code_ths()
for _, d in data.iterrows():
if d['name'] in exclude_list:
continue

    concept_list = adata.stock.info.concept_constituent_ths(index_code=d['index_code'])
    time.sleep(10)
    for _, s in concept_list.iterrows():
        try:
            k = s['stock_code']
            if k in concept:
                concept[k].append(d['name'])
            else:
                concept[k] = [d['name']]
        except Exception as e:
            print(e)

# 将概念信息转换为 JSON 字符串
conceptStr = json.dumps(concept, ensure_ascii=False, indent=4)

# 写入 JSON 字符串到文件
with open('concept.json', 'w', encoding='utf-8') as f:
    f.write(conceptStr)

@oneweek20169902
Copy link
Author

状态错点了

@1nchaos 1nchaos reopened this Oct 18, 2024
@1nchaos
Copy link
Owner

1nchaos commented Oct 18, 2024

名称会有点问题,你先获取概念列表,有指数代码

@oneweek20169902
Copy link
Author

我就是根据指数代码获取的呀

@1nchaos
Copy link
Owner

1nchaos commented Oct 21, 2024

同花顺需要低频访问,你看看是不是网络问题,或者使用代理

@oneweek20169902
Copy link
Author

我的间隔时间放到30s,第二次获取就失败了,你可以试一下

@oneweek20169902
Copy link
Author

http 请求返回Nginx forbidden.

request info: 118.112.116.238

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants