Comments (4)
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:
- 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
- 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.
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.
@sreecodeslayer Looks very promising. Please try to sketch a PR. I will be able to help if needed.
from crawly.
Sure, I'll try this over the weekend!
Am thinking of having two ways of configuration for this.
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- 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)
- Generic `Pipeline crash` error HOT 4
- [question] scrapping dynamic urls HOT 1
- `Could not start application crawly` when trying to enter IEx HOT 2
- js render problem HOT 6
- custom parsar callback sample HOT 7
- Could not compile dependency :epipe HOT 5
- Demo page not loading HOT 3
- Setting up a parametric spider (dynamic base_url and start_urls) HOT 1
- Use a more reliable website to crawl in tutorial HOT 1
- Any working examples? HOT 4
- jl files not found probably not writing HOT 1
- Crawly.fetch giving 301 response instead of 200 HOT 1
- My Spider's code is never invoked, weird behavior with `Crawly.RequestsStorage.pop` in library code HOT 5
- This is actually a question, Nested scraping HOT 2
- Genserver time out crash in long-running pipeline HOT 1
- Stop and resume the spider where it stopped HOT 2
- Protocol error HOT 7
- `Crawly.Fetchers.Fetcher` implementation for Playwright HOT 4
- robots.txt matching is pretty buggy HOT 10
- Running many instances of one spider HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from crawly.