![]() Get Multiuse News Results for multiuse_index, multiuse_news in enumerate(matched_string_json_multiuse): Get Top News Video Results for top_news_video_index, top_news_video in enumerate(matched_string_json_video): Get Top News Results for top_news_result_index, top_news in enumerate(matched_string_json_stream): "exchangeTimezoneName": "America/New_York", If you want to iterate over specific stocks, then you can skip this step and write few functions just to iterate over specific stock results. for key, value in dict(matched_string_json).items():īecause json response contains unique stock key symbols and creating a different function for each stock symbol will lead to a lot of code, and if some symbol will be changed in the future, it will throw an error. It will iterate over each available stock from the response instead and will substitute the correct stock key symbol with appropriate value data. ![]() items() returns a key, value pair so I don't have to specify which stock symbol to iterate over. Matched_string_json = json.loads(matched_string)Īfter that, the for key, value in dict(.).items() option was used to make the code shorter and easier. Next is to extract the data and convert it to iterable JSON string since re.findall() returns a list, ''.join() making it a string to use json.loads() in the next step. Note: There's obviously a better regex that could be used, I used the easiest, a very basic one. Here's a screenshot to see what is being captured ( link to regular expression): Then, regular expression comes into play to extract JSON string from the tag. Just copied the stock name and pasted it in the source code and checked if there's a match under the tags.Īfter several matches were found in the same place under the tag I began to look where the tag starts and ends in order to extract the correct one using regular expression. The way I found where the data is located is very simple. Here's what UI looks like: Get header stock resultsįirstly, we need to locate where the data is located since we can't just use CSS selectors to extract the data because it is dynamically updating from the server. You can access and navigate through header stock results, news results json string data at jsonblob here.ĭadroit was used to preview json and copy paths to a specific key, value. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |