Crawler Detection in Cloudflare Worker

Can we revisit this? Any way to detect IF crawler using cloudflare worker on PRO plan?
24 Replies
Retard
RetardOP•2y ago
Thanks for any help 🙂
kian
kian•2y ago
kian
kian•2y ago
Transform Rule -> Modify Request Header -> this -> Read X-Verified-Bot header in your Worker
Retard
RetardOP•2y ago
This is done
Retard
RetardOP•2y ago
Can you please assist with Bot Level Code? Simple as this? const bot = req.headers.get('X-Verified-Bot'); if bot = ('Bot1|Bot2|Bot3|Bot4')
kian
kian•2y ago
bot is just true or false
Retard
RetardOP•2y ago
REVISED: const bot = req.headers.get('X-Verified-Bot'); if bot == true { you win } @kiannh
dave
dave•2y ago
cf.client.bot isn't pro?
kian
kian•2y ago
Anyone can have it
dave
dave•2y ago
interesting, any other headers you know of that are helpful to pass in like that? Currently I pass in the timestamp, gonna add X-Verified-Bot too
kian
kian•2y ago
See if any of those sound interesting for your use-case Of course, cf.bot_management.* is Enterprise
dave
dave•2y ago
hang on, why can't we use botManagement? erm I mean req.cf.botManagement.verifiedBot
kian
kian•2y ago
because that's an Enterprise add-on if you mean it's available to you right now when you're not on an Enterprise plan, don't rely on that staying
dave
dave•2y ago
dave
dave•2y ago
how's that look? ah many of those are ent only
dave
dave•2y ago
dave
dave•2y ago
this is what I ended up with
Retard
RetardOP•2y ago
Wait, guys, did I get this right? const bot = req.headers.get('X-Verified-Bot'); if bot == true { Can someone confirm please, not too familiar with workers?
kian
kian•2y ago
Seems fine to me Only good bots will be true - so stuff like Googlebot, Bingbot, etc Any random scraper will still be false
Retard
RetardOP•2y ago
That should stop them 😄
Retard
RetardOP•2y ago
Google banned our Shopping Account because they cant see pricing, which we hide for most visitors. Now, the goal, is to show them pricing so they can leave us alone 😄
dave
dave•2y ago
doesn't google also ban if they figure out you're offering them different prices than everyone else?
Retard
RetardOP•2y ago
Yea, they're sensitive. Thats not the case tho To elaborate, we hide pricing for normal users. When they are sent the /pricing/ link a cookie is inserted that enables pricing on main site. Just want to hide pricing from the normal user is all. This pissed google off due to "Checkout Experience Broken" So hoping above code will enable pricing/set pricing for google crawler and they can chill. We aren't lying, just giving them access
Want results from more Discord servers?
Add your server