News for hackers. Stuff that matters.
Re:Avoiding bot detection: How to scrape the web without get... by marginalia_nu on Sunday October 31, 2021 @07:25PM (#29061458)
If someone is signalling to you you that they do not want your bot on their site, then maybe respect that? Trying to circumvent it is besides being legally questionable, a serious pain in the ass for the site owner and makes websites more prone to attempt to block bots in general.

Also, in my experience, most websites that block your bot, block your bot because your bot is too aggressive, or because you are fetching some resource that is expensive that bots in general refuse to lay off. Bots with seconds between the requests rarely get blocked even by CDNs.

Re:Avoiding bot detection: How to scrape the web without get... by soheil on Sunday October 31, 2021 @07:31PM (#29061485)
Google can access any site without being blocked. They dominate the search space and give little incentive for site owners to allow other bots. I'd say bypassing these measures is fair game while there is a monopoly in search space. We don't want a web that only Google can access.

By the way great work on Marginalia search engine, I love it.

Re:Avoiding bot detection: How to scrape the web without get... by marginalia_nu on Sunday October 31, 2021 @07:40PM (#29061555)
I've honestly not had much problem at all crawling the web as an indie search engine operator. If you want to get past CloudFlare you can register your bot fingerprint with them.

A small number of sites has blocked my crawler , but that's almost always been my own fault, and happened a few instances when the crawler was misbehaving and actually fetching too aggressively (or repeatedly). In every case just sending an email to the site explaining what happened and humbly asking for a second chance been enough to be allowed back in.

Most website owners don't seem to mind small search engines at all, what they don't want is scrapers that aggressively scrape their entire site 10 times a day, ignoring robots.txt, and being a general nuisance.

Re:Avoiding bot detection: How to scrape the web without get... by kristjansson on Sunday October 31, 2021 @09:36PM (#29062226)
There's also the alignment of interests between you and the site operators, even for a small search engine. Cooperation improves outcomes for both sides. Whereas the more aggressive scrapers almost certainly have interests that conflict with the site operators, regardless of the costs to serve the traffic itself.
Re:Avoiding bot detection: How to scrape the web without get... by gzer0 on Sunday October 31, 2021 @09:02PM (#29062054)
How did you go about registering your bot fingerprint with Cloudflare? I did a quick search but cannot find anything with regards to that.
Re:Avoiding bot detection: How to scrape the web without get... by marginalia_nu on Sunday October 31, 2021 @09:17PM (#29062135)
Good question, I can't find the link now either. I found it somewhere on Cloudflare's site.

--edit--

Nevermind, here it is: https://support.cloudflare.com/hc/en-us/articles/36003538743...

It should skip to "I run a good bot...", but if it doesn't, that's where you want to scroll.

Re:Avoiding bot detection: How to scrape the web without get... by jonatron on Sunday October 31, 2021 @07:35PM (#29061513)
Legitimate uses of scraping include price comparison, and finding copyright or trademark infringement.
Re:Avoiding bot detection: How to scrape the web without get... by Dah00n on Sunday October 31, 2021 @07:42PM (#29061571)
>Legitimate uses of scraping include price comparison

"Legitimate uses" is what the site operator says it is, nothing more nothing less. There are no laws that says you can scrape a site and circumvent their protection against doing so.

Re:Avoiding bot detection: How to scrape the web without get... by EMIRELADERO on Sunday October 31, 2021 @07:56PM (#29061669)
On the contrary, there are no laws that say you can't scrape a site. If it's available to the public internet, it's legally scrapable.
Re:Avoiding bot detection: How to scrape the web without get... by marginalia_nu on Sunday October 31, 2021 @08:05PM (#29061717)
There are laws against unauthorized computer access.

This is a scenario where you have a server explicitly saying "Stop! You are not permitted to access this computer!", and yet you persist in circumventing that by hiding your identity and accessing it anyway. Those are some murky waters.

Re:Avoiding bot detection: How to scrape the web without get... by fragmede on Sunday October 31, 2021 @11:44PM (#29062805)
For those that are interested in the specifics, Jamie Williams wrote a piece for the EFF[0] in the wake of hiQ vs Linkedin which dealt with this exact question.

It depends on who the server operator is. If it's your server, yeah, anyone I don't want to be there should go away. If it's your enemy's server, the argument that they're sending that page to the rest of the Internet turns out to be a decent one.

[0] https://www.eff.org/deeplinks/2018/04/scraping-just-automate...

Re:Avoiding bot detection: How to scrape the web without get... by Aeolun on Sunday October 31, 2021 @08:19PM (#29061802)
The server says nothing of the kind. The response that was previously positive is now broken, and it happens to be fixed if you access it from a different IP.

Maybe we need a status code that means ‘lay off all the requests made from this entire system’?

Re:Avoiding bot detection: How to scrape the web without get... by marginalia_nu on Sunday October 31, 2021 @08:28PM (#29061856)
How do you interpret a

401 Unauthorized

to mean you are authorized to access the resource?

Re:Avoiding bot detection: How to scrape the web without get... by jhgb on Sunday October 31, 2021 @09:29PM (#29062182)
https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#cli...

> Although the HTTP standard specifies "unauthorized", semantically this response means "unauthenticated". That is, the client must authenticate itself to get the requested response.

So it would seem that it actually doesn't positively imply that you're NOT authorized.

Which kind of makes sense; machines can't detect legality of things, just that certain procedural niceties haven't been observed.

Re:Avoiding bot detection: How to scrape the web without get... by marginalia_nu on Sunday October 31, 2021 @09:41PM (#29062252)
Fine, send a 403 then.

> The client does not have access rights to the content; that is, it is unauthorized, so the server is refusing to give the requested resource.

Machines don't have any legal responsibility, bot-operators do. Which is why respecting these things is sort of important. At any rate, 40x does not mean "try again with a different user agent and another IP"

Re:Avoiding bot detection: How to scrape the web without get... by hattmall on Monday November 01, 2021 @12:33AM (#29063019)
403 is per request, not requester. I get random 403s when just browsing some websites. Does that mean I should close the browser and not hit refresh for fear of breaking some wire fraud unauthorized access law?
Re:Avoiding bot detection: How to scrape the web without get... by marginalia_nu on Monday November 01, 2021 @04:55AM (#29064351)
If you go by the semantics of what the 403 code means, absolutely, that's excatly what the status code means.

In practice there's of course nuance, like anyone will occasionally type in the wrong password on a log-in screen, maybe try again and then realize it was the wrong log-in prompt. That's mostly fine.

That's different from deliberate trying to circumvent a measure like this. If you are doing the stuff in the link, you are absolutely crossing a line and you know it.

There's a large difference between "I got a 403 so I hit F5 once" and "I got a 403 so I used a residential proxy and spoofed my user-agent".

Re:Avoiding bot detection: How to scrape the web without get... by jhgb on Monday November 01, 2021 @08:23AM (#29065793)
I thought the semantics of 403 was "look for the actual semantics in the response body".
Re:Avoiding bot detection: How to scrape the web without get... by BeFlatXIII on Tuesday November 02, 2021 @08:38AM (#29080302)
If I were on a jury, I’d vote to nullify any scraping case that made it this far.
Re:Avoiding bot detection: How to scrape the web without get... by dragonwriter on Sunday October 31, 2021 @08:00PM (#29061696)
> On the contrary, there are no laws that say you can't scrape a site.

You are both wrong: copyright law both says you can't (in some cases for some uses) and that you can (under implicit license, fair use, and other rules) in others.

Re:Avoiding bot detection: How to scrape the web without get... by EMIRELADERO on Sunday October 31, 2021 @09:38PM (#29062240)
Depends on what exactly is being scraped. If it's something like price data or exact values then it isn't protected by copyright at all.
Re:Avoiding bot detection: How to scrape the web without get... by kingcharles on Monday November 01, 2021 @02:01AM (#29063450)
Price data can be protected by copyright as a compliation of data.

https://www.bitlaw.com/copyright/database.html

Re:Avoiding bot detection: How to scrape the web without get... by EMIRELADERO on Monday November 01, 2021 @10:51AM (#29067311)
In that case, the data compilation itself would be protected, not the individual data points. If I used a scraper to copy everything verbatim, then yes, it would be a violation.
Re:Avoiding bot detection: How to scrape the web without get... by jonatron on Sunday October 31, 2021 @08:19PM (#29061806)
If you look at Ryanair, they've had legal battles with scrapers for more than 10 years, so it's not that simple.
Re:Avoiding bot detection: How to scrape the web without get... by aembleton on Monday November 01, 2021 @05:10AM (#29064429)
I found Ryanair one of the more friendly ones to scrape, albeit for my own personal project. When you query for flights, they make a GET request with a JSON object in response, complete with flight times and prices.

For example:

  curl "https://www.ryanair.com/api/booking/v4/en-gb/availability?ADT=1&CHD=0&DateIn=&DateOut=2021-11-15&Destination=BER&Disc=0&INF=0&Origin=MAN&TEEN=0&promoCode=&IncludeConnectingFlights=false&FlexDaysBeforeOut=2&FlexDaysOut=2&ToUs=AGREED" | jq
Re:Avoiding bot detection: How to scrape the web without get... by jonatron on Monday November 01, 2021 @05:29AM (#29064563)
I haven't tried to scrape Ryanair, you could be right that it's trivial. It's the legal side that has a long and interesting history. Personally I wouldn't scrape them unless it was when working for a company that can afford lawyers.
Re:Avoiding bot detection: How to scrape the web without get... by shapefrog on Monday November 01, 2021 @05:34AM (#29064590)
{"code":"TermsOfUseAreNotAccepted","message":"TermsOfUseAreNotAccepted"}
Re:Avoiding bot detection: How to scrape the web without get... by kzrdude on Monday November 01, 2021 @04:55AM (#29064346)
I would say legitimate use includes archiving, and nothing more.
Re:Avoiding bot detection: How to scrape the web without get... by matheusmoreira on Monday November 01, 2021 @07:34AM (#29065394)
> If someone is signalling to you you that they do not want your bot on their site, then maybe respect that?

Maybe respect user freedom? If I can access the data using my browser, why can't I access it using my script?

Why is Google the only one who can do it? Must they have yet another monopoly?

> Bots with seconds between the requests rarely get blocked even by CDNs.

I've had scripts that made 1 request per day get blocked for no reason. Not to mention the endless cloudflare javascript bullshit they made me support for it to even work.

Re:Avoiding bot detection: How to scrape the web without get... by marginalia_nu on Monday November 01, 2021 @08:02AM (#29065611)
> Why is Google the only one who can do it? Must they have yet another monopoly?

I run a search engine and do my own crawling, and this does not correspond to my view of reality at all.

I have had almost no problems with getting blocked. If I have gotten blocked, it's usually been my own fault and I've been able to get unblocked by sending them an email explaining I run a search engine and asking for forgiveness because my bot wasn't behaving well.

The bots that do get blocked are bots in most cases bots that misbehave, ignore robots.txt, fetch the same resources repeatedly or with insane crawl-delays.

There are a few rare exceptions, but the whole "why does Google get a free pass when I don't?"-angle just doesn't hold water at all.

> I've had scripts that made 1 request per day get blocked for no reason. Not to mention the endless cloudflare javascript bullshit they made me support for it to even work.

Google doesn't repeat requests every day. I don't repeat requests every day. That's a weird thing to do, and it's well within a site owner's prerogative to block that nonsense.

Re:Avoiding bot detection: How to scrape the web without get... by matheusmoreira on Monday November 01, 2021 @08:32AM (#29065870)
> Google doesn't repeat requests every day. I don't repeat requests every day.

I scrape one site whose content changes every second. How is it "nonsense" to make one request every 24 hours? I make hundreds, thousands when I browse their site normally using my browser.

We've got people in this very thread talking about bots making hundreds of requests per second. How is one request every 24 hours harming anyone? People told me to make one request per hour to avoid hammering their servers, I decided to wait a day instead. It boggles my mind that this generous interval could possibly be considered abuse. How long should the interval be then? A month? A year? Infinitely long so the scraper never makes requests?

Re:Avoiding bot detection: How to scrape the web without get... by colinmhayes on Monday November 01, 2021 @09:24AM (#29066358)
I built a search engine in school. I was lazy and stupid with the scraper and ended up writing a bug that caused it to loop on certain sites. That lead to the entire Duke law school site being DOS's during their class sign up period. Sorry for ruining scraping for everyone, but this is why websites don't want people scraping them.
Re:Avoiding bot detection: How to scrape the web without get... by Spivak on Monday November 01, 2021 @11:03AM (#29067535)
But you have no freedom when contacting my servers. I can send you 403's just because I don't like your face. There is zero entitlement that you have any access to my servers in any way I don't permit. If I say no automated access then on what grounds to you have to do it anyway?

> Why is Google the only one who can do it?

Because site operators explicitly allow them automated access. If you want the same treatment you have to ask for it.

Re:Avoiding bot detection: How to scrape the web without get... by matheusmoreira on Monday November 01, 2021 @11:21AM (#29067854)
> I can send you 403's just because I don't like your face.

Sure. At least then you're being honest. If you hate me, it doesn't matter what user agent I use to access your site. Browsers, scripts, they are all me.

Re:Avoiding bot detection: How to scrape the web without get... by Spivak on Monday November 01, 2021 @12:15PM (#29068794)
Why do you think it’s dishonest to send 403s to bots but not browsers? Method of access matters — you the human might have access to your safety deposit box but the bank is still allowed to make rules about your access — like you have to come during business hours and you can’t send someone on your behalf.
Re:Avoiding bot detection: How to scrape the web without get... by matheusmoreira on Tuesday November 02, 2021 @02:11PM (#29085178)
> you can’t send someone on your behalf

I totally can though. If sign a document saying another person can do such and such on my behalf, that person can totally do that. Yes, even at the bank. No different from a user agent, really.

Re:Avoiding bot detection: How to scrape the web without get... by hbgl on Monday November 01, 2021 @09:51AM (#29066615)
> Why is Google the only one who can do it? Must they have yet another monopoly?

Google can do it because most website operators want them to index their site. Plus, it is trivial to tell google to stop. That goes for all search engines.

Re:Avoiding bot detection: How to scrape the web without get... by TruthWillHurt on Sunday October 31, 2021 @07:35PM (#29061509)
You're forgetting a case where a website offers a garbage API that doesn't provide all the data available via the web interface,

either due to neglegance (Apple Store developer console),

Security (Google Play Store accounting data),

Or financial gain (AppsFlyer "premium API").

Re:Avoiding bot detection: How to scrape the web without get... by Dah00n on Sunday October 31, 2021 @07:45PM (#29061592)
That doesn't change anything. The site owner decides what you can and cannot do. If a badly made API meant you could do anything you wanted to then everything could be done to those sites running them. That is not how this work. Outside normal usage you need permission.
Re:Avoiding bot detection: How to scrape the web without get... by temp8964 on Sunday October 31, 2021 @10:37PM (#29062533)
I really don't believe "The site owner decides what you can and cannot do." statement. What is the base of this? This does not seem to apply to anything in the real world.

In most cases you have very limited ability to decide what other people cannot do. And other people has mostly infinite choices of what they can do. I never heard anything as broad as you said. What you said is like a person standing on the street with a T-shirt says "do not look at me more than twice" and claim it has a legal binding to the whole world.

Re:Avoiding bot detection: How to scrape the web without get... by arp242 on Sunday October 31, 2021 @11:07PM (#29062669)
> I really don't believe "The site owner decides what you can and cannot do." statement. What is the base of this? This does not seem to apply to anything in the real world.

It kind of does though; if I own a store and say that only people with hats can enter, then I'm free to do so. Silly? Yes. Legal? Also yes.

There are some circumstances where it's not legal, mostly centred around discrimination. Details on this differ per jurisdiction, but generally speaking you have a right to refuse customers.

Re:Avoiding bot detection: How to scrape the web without get... by geysersam on Monday November 01, 2021 @02:26AM (#29063600)
Interesting discussion.

To me it seems sending a http request is somewhere inbetween looking (legal) and entering (illegal if not permitted).

However, most important is that the web as a system makes positive interactions easy and negative difficult. We have already found some set of constraints achieving this for interactions in public city streets. But it's not obvious the same rules (that we have internalized) have the same effect in another medium of communication.

Re:Avoiding bot detection: How to scrape the web without get... by boolemancer on Sunday October 31, 2021 @08:33PM (#29061889)
If I can access the information in Chrome, I should be able to access the information with my own client, and the site operator shouldn't have any say in that.
Re:Avoiding bot detection: How to scrape the web without get... by oefrha on Sunday October 31, 2021 @11:51PM (#29062830)
> Also, in my experience, most websites that block your bot, block your bot because your bot is too aggressive, or because you are fetching some resource that is expensive that bots in general refuse to lay off. Bots with seconds between the requests rarely get blocked even by CDNs.

Tell that to any Cloudflare site on security level High or "I'm Under Attack!" year round.

Re:Avoiding bot detection: How to scrape the web without get... by marginalia_nu on Monday November 01, 2021 @04:56AM (#29064356)
Usually means they have large ongoing problems with aggressive bots.
Re:Avoiding bot detection: How to scrape the web without get... by herbst on Monday November 01, 2021 @05:18AM (#29064494)
Or they using it as lazy approach to fix long-dos attacks by competitors.
Re:Avoiding bot detection: How to scrape the web without get... by marginalia_nu on Monday November 01, 2021 @07:41AM (#29065439)
What is the non-lazy alternative that stops a botnet DDOS without affecting regular visitors?
Re:Avoiding bot detection: How to scrape the web without get... by herbst on Tuesday November 02, 2021 @06:12AM (#29079135)
Long-dos is usually not a botnet but a single or a few attackers requesting a resource heavy page on and on or using a technic like slowloris. If you are using WordPress I am sure you find some signs in your log.

The solution other than with ddos is to make the app better. Caching, access control and limiting, etc.

Re:Avoiding bot detection: How to scrape the web without get... by svnpenn on Monday November 01, 2021 @12:59AM (#29063146)
> Also, in my experience, most websites that block your bot, block your bot because your bot is too aggressive

Obviously you haven't used Instagram recently.

Re:Avoiding bot detection: How to scrape the web without get... by hcta on Sunday October 31, 2021 @09:13PM (#29062113)
I'm a bot, you're a bot, we are all bots, so what does this even mean. If someone is trying to discriminate between one set of visitors that they welcome and another that they deny service to, by definition they are the ones creating an adversarial environment. They are going to have to work to get the terms they want. Asking the players on the opposite side of the table to comply with their imagined rules out of altruism is a non-starter.
Re:Avoiding bot detection: How to scrape the web without get... by hbgl on Sunday October 31, 2021 @10:21PM (#29062456)
Technically it should be illegal to scrape websites without the consent of the server owner because it would be a violation of their property rights. That being said, I think that in reality it would be pretty difficult to get courts to agree with you and then to enforce it.