duck-dynasty / duckbot

A Discord bot for personal friend group
GNU General Public License v3.0
9 stars 10 forks source link

add `!google` command to scrape the top result from google #86

Open twentylemon opened 3 years ago

twentylemon commented 3 years ago

So, you could ask something like are peas legumes and get back the top blurb.

Human: !google are peas legumes DuckBot: Legumes — a class of vegetables that includes beans, peas and lentils — are among the most versatile and nutritious foods available. Legumes are typically low in fat, contain no cholesterol, and are high in folate, potassium, iron and magnesium. They also contain beneficial fats and soluble and insoluble fiber. https://www.mayoclinic.org/healthy-lifestyle/nutrition-and-healthy-eating/in-depth/legumes/art-20044278

twentylemon commented 3 years ago

https://serpstack.com/ gives 100 free requests per month. The best free API option I found.

lapp14 commented 3 years ago

I know its probably way slower, but cant we just beautifulsoup the top result? That would get us unlimited access straight from a google webpage.

twentylemon commented 3 years ago

Yeah, for sure, but the top result is all over the place. There's the result card, there's the left side bar, or there's the top link. Then, stuff like "other questions" and such. It's pretty complex. We can have a basic one that scrapes, but it'll be way harder to add more features, and it'd be more fragile.