【发布时间】:2021-09-21 10:15:28
【问题描述】:
我想从这个link 中提取所有short_name
我已经尝试过关注这个answer,但它失败了。我得到的结果是'None'。
这是我的代码:
def checkStockIdExistOrNot(stockIdNumberOrName):
BursaStockSearchIdURL = 'https://www.bursamalaysia.com/api/v1/search/stock_list?keyword=' + str(stockIdNumberOrName) + '&lang=EN&limit=99'
BursaStockSearchIdRequest = requests.get(str(BursaStockSearchIdURL), headers=header)
BursaStockSearchIdParser = BeautifulSoup(BursaStockSearchIdRequest.content, 'html.parser')
BursaSelection = BursaStockSearchIdParser.find('pre')
print(BursaSelection)
checkStockIdExistOrNot('SERBADK')
我的意图是只获得short_name SERBADK 和 SERBADK-C17。
但是,由于 'None' 的值,我无法从中选择/挑选任何单个数据。
谢谢!
【问题讨论】:
标签: python web-scraping beautifulsoup tags