Giter Club home page Giter Club logo

Comments (4)

oltarasenko avatar oltarasenko commented on May 14, 2024 1

From practice:
Sometimes it's a pain to find an appropriate set of user agents for a given website :( Just as you have stated, they would render something completely different in some cases. Also in some cases, we were pretending to be old android devices, which allowed to query API directly.

So what I want to have:

  1. Possibility to override user agent strings with just string (as it's done now). So in these cases it's possible to chose something more concrete
  2. Generate user agent string based on a category: mobile/desktop/etc from the Faker API

Suggestions:
Currently, user agents are handled in the https://github.com/oltarasenko/crawly/blob/master/lib/crawly/middlewares/user_agent.ex.

Maybe we can make a twist here, to just call Faker.Internet.UserAgent.desktop_user_agent() (or similar) if user agents are not provided as a list... It sounds a bit untidy, but let's start playing with it, to see, maybe we will find a clean way of directing the code to Faker

from crawly.

sreecodeslayer avatar sreecodeslayer commented on May 14, 2024

Hey @oltarasenko , just stumbled upon this issue today. I'd suggest Faker's internet UserAgent module!
Let me know if you need help, i'll try to chip in a PR if possible!

from crawly.

oltarasenko avatar oltarasenko commented on May 14, 2024

@sreecodeslayer Looks very promising. Please try to sketch a PR. I will be able to help if needed.

from crawly.

sreecodeslayer avatar sreecodeslayer commented on May 14, 2024

Sure, I'll try this over the weekend!

Am thinking of having two ways of configuration for this.

  1. The users should have an option to set default list of user-agents that they wish to use, under configuration. The items from the list can then be chosen randomly when setting up request options. Oops! Looks like I spoke too soon. I think this is already possible
  2. By default, Crawly should fallback to an item from Faker.Internet.UserAgent. Now one thing to be aware here is the use of random user agents. ie., Using a mobile user agent on websites can at times mess up the xpaths [when the website supports both devices using separate css classes and what not!]. So it might be better to have this [type-of-user-agent-device] as a config upfront if the user is not setting a default list of user-agents

Your thoughts? 😄

from crawly.

Related Issues (20)

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.