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

Harrison/add to search #778

Merged
merged 2 commits into from
Jan 28, 2023
Merged

Harrison/add to search #778

merged 2 commits into from
Jan 28, 2023

Conversation

hwchase17
Copy link
Contributor

No description provided.

conceptofmind and others added 2 commits January 28, 2023 07:46
Hi @hwchase17,

Per our previous discussion, I am updating the Google and Bing Search
API utilities to include a method for returning metadata in the form
`[{'snippet':'hello world', 'title': 'foo', 'link': 'bar'}]`.

Usage:
```python
search = GoogleSearchAPIWrapper()
search.results(query="apples", num_results=2)
```
Output:
```
[{'snippet': 'Lady Alice. Pink Lady <b>apples</b> aren’t the only lady in the apple family. Lady Alice <b>apples</b> were discovered growing, thanks to bees pollinating, in Washington. They are smaller and slightly more stout in appearance than other varieties. Their skin color appears to have red and yellow stripes running from stem to butt.', 'title': '25 Types of Apples - Jessica Gavin', 'link': 'https://www.jessicagavin.com/types-of-apples/'}, {'snippet': '<b>Apples</b> boast many vitamins and minerals, though not in high amounts. However, <b>apples</b> are usually a good source of vitamin C. Vitamin C. Also called ascorbic acid, this vitamin is a common ...', 'title': 'Apples 101: Nutrition Facts and Health Benefits', 'link': 'https://www.healthline.com/nutrition/foods/apples'}]
```

I also standardized the GoogleSearchAPIWrapper to allow you to select
`k` number of results similar to the BingSearchAPIWrapper.

Usage:
```python
search = GoogleSearchAPIWrapper(k=1)
search.run("python")
```
Output:
```'The official home of the Python Programming Language.'```

I commented out the line, `default="https://api.bing.microsoft.com/v7.0/search"`, in the Bing Search API Wrapper and think it may be worth investigating as this was throwing an error for me.

I updated the documentation to include newer examples as well.

Let me know what you think.

Thank you,

Enrico Shippole
@hwchase17 hwchase17 merged commit c658f0a into master Jan 28, 2023
@hwchase17 hwchase17 deleted the harrison/add-to-search branch January 28, 2023 16:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants