{ "info": { "author": "Rob Truxal", "author_email": "rtruxal2020@outlook.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 1 - Planning", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "Intro\n=====\n\nVERSION=0.0.2 | supports Python 2.7\n\n\n####An Overly Explanatory Intro to Cognitive Services aka Bing Search API v5\n\n This code has been designed as a teaching tool. Where applicable, efficiency has been sacrificed to make functionality clear. The first file you should check out is `py-cog-serv.source.constants`. Snippits of it are shown in the \"Usage\" section below. As of now, this tool supports only basic web-search. Contributions are welcome and needed!\n\n\nInstallation\n============\nThis module is not yet packaged. Until then, here is a sample import into REPL.\nThe following assumes your current working directory is `.../PATH/TO/py-cog-serv`\n```py\n>>> import os, sys\n>>> sys.path.append(os.getcwd())\n>>> from source.SearchWeb import BingWebSearch\n```\n\n\nUsage\n=====\n####Step 1: Customize Headers & Optional Query Params\n You'll notice that `constants.py` has two classes included in it: `user_constants` and `static_constants`.\n * `user_constants` gives access to the default headers and query-modifiers used when a `BingWebSearch` object is instantiated.\n * `static_constants` can be used as reference. Check out:\n * `static_constants.COUNTRY_CODES`\n * `static_constants.MARKET_CODES`\n * `static_constants.SPECIALTY_APIS`\n * `static_constants.BASE_ENDPOINT` as well as the alternative formats of the other `static_constant.XXX_ENDPOINT`s listed.\n\nStudy the constants page, it will guide you through the decisions you're in charge of making. The tool will take care of their implementation. Do **NOT** enter your key into the header in step 1. It must be passed manually to the constructor in step 2.\n\nFrom `source.constants.user_constants`:\n```py\n ###############################################\n ## Enter default-header customizations here. ##\n ###############################################\n HEADERS['Ocp-Apim-Subscription-Key'] = None\n HEADERS['User-Agent'] = user_agent.firefox\n HEADERS['X-Search-ClientIP'] = gethostbyname(gethostname())\n HEADERS['X-MSEdge-ClientID']= None\n HEADERS['Accept'] = None\n HEADERS['Accept-Language'] = None\n HEADERS['X-Search-Location'] = None\n\n ###############################################\n ## Enter query customizations here. ##\n ###############################################\n ## Web Params:\n INCLUDED_PARAMS['cc'] = None # <--(See static_constants.COUNTRY_CODES below for available options)\n INCLUDED_PARAMS['count'] = None # <--(Enter a number from 0-50. Must by type==str. EX: count of 5 should be \"5\")\n INCLUDED_PARAMS['freshness'] = None # <--(Poss values are 'Day', 'Week', or 'Month')\n INCLUDED_PARAMS['mkt'] = None # <--(See static_constants.MARKET_CODES below for available options)\n INCLUDED_PARAMS['offset'] = None # <--(Use this in conjunction with totalEstimatedMatches and count to page. Same format as 'count')\n INCLUDED_PARAMS['responseFilter'] = None # <--(Poss values are 'Computation', 'Images', 'News', 'RelatedSearches', SpellSuggestions', 'TimeZone', 'Videos', or 'Webpages')\n INCLUDED_PARAMS['safeSearch'] = None # <--(Poss values are 'Off', 'Moderate', and 'Strict.')\n INCLUDED_PARAMS['setLang'] = None # <--(See ISO 639-1, 2-letter language codes here: https://www.loc.gov/standards/iso639-2/php/code_list.php)\n INCLUDED_PARAMS['textDecorations'] = None # <--(Case-insensitive boolean. '(t|T)rue', or '(f|F)alse')\n INCLUDED_PARAMS['textFormat'] = None # <--(Poss values are 'Raw', and 'HTML.' Default is 'Raw' if left blank.)\n```\n\n\n####Step 2: Search For Web Results:\n```py\n>>> from py-cog-serv.source.SearchWeb import BingWebSearch\n>>> search_query = \"ENTER YOUR ARBITRARY SEARCH TERMS HERE\"\n>>> web_searcher = BingWebSearch(api_key=api_key, query=search_query, safe=False, headers=constants.HEADERS, addtnl_params=constants.INCLUDED_PARAMS)\n>>> # see source.constants.static_constants.BASE_QUERY_PARAMS for compatible params. Must be in {param : value} format\n>>> return_json = web_searcher.search(limit=50)\n>>> # 50 is the maximum number results returned per query. Pagination is in the works.\n```\n\n\n\nNotes\n=====\n\n2016-11-15: Added support & checking-mechanism for web-search query parameters\n\n\nMassive swaths of this v5 API interface were graciously stolen from py-bing-search which you can find here: https://github.com/tristantao/py-bing-search\n\n\nI AM NOT A PROFESSIONAL PROGRAMMER AND JUST STARTING THIS.\n\nPLEASE HELP ME MAKE THIS NOT AWFUL.\n\n\nTODO\n=====\n* Parse the return JSON!...like any of it! just do something it's a mess!\n* Add image/news/video classes w/ support for API-specific querying\n * Base Endpoint URLs for these are partially built in class \"constants\"\n* Fix query params-checking. **FINISHED-(ALPHA)**\n* Parse queries into URLs better. **FINISHED-(ALPHA)**\n * Use requests.utils.quote or some-such to encode things properly.\n* Set up error handling for query/second errors. Use time.sleep(1).\n* Implement paging with self.current_offset.\n* Ensure Python3 compatibility w/ try: except: statement for manual header entry.\n * (Currently using `raw_input`)", "description_content_type": null, "docs_url": null, "download_url": null, "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/rtruxal/py-cog-serv", "keywords": "Azure,Bing,API,Search,Cognitive Services,v5", "license": "MIT", "maintainer": null, "maintainer_email": null, "name": "py-cog-serv", "package_url": "https://pypi.org/project/py-cog-serv/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/py-cog-serv/", "project_urls": { "Homepage": "https://github.com/rtruxal/py-cog-serv" }, "release_url": "https://pypi.org/project/py-cog-serv/0.0.2/", "requires_dist": null, "requires_python": null, "summary": "A simple lightweight python wrapper for the Azure Bing Search API.", "version": "0.0.2" }, "last_serial": 2467963, "releases": { "0.0.2": [] }, "urls": [] }