Code Monkey home page Code Monkey logo

gscraper's Introduction

GScraper

A collection of search engine image scrapers (Google Images, DuckDuckGo and Brave) in C#.

See the examples folder for an example program.

gscraper's People

Contributors

d4n3436 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

gscraper's Issues

HttpClient does not respect IDisposable

Hello,

As per this article from Microsoft https://learn.microsoft.com/en-us/dotnet/fundamentals/networking/http/httpclient-guidelines HttpClient does not respect the IDisposable interface. If this is used in Asp.Net it could lead to socket exhaustion from too many connections.

Basically the Scraper classes shouldn't implement IDisposable and dispose of the HttpClient, this is from the article listed above:

Any reasonably limited number of HttpClient instances will work as well. What matters here is that they are not created and disposed with each request as they each contain a connection pool. Using more than one instance is necessary for scenarios with multiple proxies or to separate cookie containers without completely disabling cookie handling.

Would you be open to a PR that would also add some interfaces to better use/register classes in ASP.net dependency injection container and removes this interface?

Here's some additional reading on how it's used in ASP.net =>https://learn.microsoft.com/en-us/aspnet/core/fundamentals/http-requests?view=aspnetcore-7.0#named-clients

error when using google scraper

code is here:
GoogleScraper GoogleScraper = new GoogleScraper();
IEnumerable images = await GoogleScraper.GetImagesAsync(query);
Random Random = new Random();
int image = Random.Next(0, images.Count());
message.Channel.SendMessage(images.ElementAt(image).Url);

i get this error:
GScraper.GScraperException: Failed to unpack the image object data.
---> System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'startIndex')
at System.String.IndexOf(Char value, Int32 startIndex, Int32 count)
at System.String.IndexOf(Char value, Int32 startIndex)
at GScraper.Google.GoogleScraper.ExtractDataPack(String page)
at GScraper.Google.GoogleScraper.GetImagesAsync(String query, SafeSearchLevel safeSearch, GoogleImageSize size, String color, GoogleImageType type, GoogleImageTime time, String license, String language)
--- End of inner exception stack trace ---
at GScraper.Google.GoogleScraper.GetImagesAsync(String query, SafeSearchLevel safeSearch, GoogleImageSize size, String color, GoogleImageType type, GoogleImageTime time, String license, String language)
at Ascension.โ™ .โ™ซ.MoveNext()

if i use duckduckgoscraper this doesn't happen but duckduckgo returns irrelevant images quite a lot so i'd prefer if google worked

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.