Spaces:
Runtime error
Runtime error
| from webscout import WEBS | |
| import requests | |
| def websearch_ddc(query, max_results=5, time_limit=5): | |
| response = requests.get(f"https://oevortex-webscout-api.hf.space/api/search?q={query}&max_results={max_results}&timelimit={time_limit}&safesearch=off®ion=wt-wt") | |
| return response.json()['results'] | |
| def attributes_ext(json_data): | |
| # Initialize empty lists for each key | |
| title = [] | |
| href = [] | |
| body = [] | |
| # Iterate over each item in the list and extract values for each key | |
| for item in json_data: | |
| title.append(item['title']) | |
| href.append(item['href']) | |
| body.append(item['body']) | |
| return title, href, body | |
| def main(query, max_results=10): | |
| raw_output = websearch_ddc(query, max_results=max_results) | |
| titles_list, urls_list, text_list = attributes_ext(raw_output) | |
| return titles_list, urls_list, text_list | |
| if __name__ == "__main__": | |
| # Prompt the user for a search query | |
| query = "ipl 2024" | |
| titles_list, urls_list, text_list = main(query) | |
| print(titles_list) |