Please suggest some way to present data on website in an manner that nobody is able to copy that data just exactly like justdail ( https://www.justdial.com/Delhi/Cafe-La-Pinoz-Near-Alchemist-Hospital-Sector-53/ ). Please open the URL you cannot copy phone number from this web page . I want something similar in PHP . I dont want to hide information from website just prevent user from copying or scraping data from website. No image method.
-
Possible duplicate of [How to disable selection of text on a web page](https://stackoverflow.com/questions/12315476/how-to-disable-selection-of-text-on-a-web-page) – Nakul Apr 03 '18 at 10:35
-
5Remember that a user can choose to just turn off JavaScript, so there is always a way. If you’re trying to protect something, don’t put it into the public domain. – Zoe Edwards Apr 03 '18 at 11:08
-
Please check this URL ( justdial.com/Delhi/… ) I am looking for something similar. Where scraping of phone number is not possible – Sajan Kaundal Apr 03 '18 at 12:17
-
You cannot at the same time publish information and _not_ publish it. – arkascha Apr 03 '18 at 12:43
-
2It appears that most of the content of that page consists of individual `` elements for each letter with a CSS `::before` rule filling in the actual letter. That's… yeah… somewhat insane, but also somewhat effective at preventing casual copy and paste. Which also makes it extremely user hostile. And it's still very possible to write a custom scraper for that obfuscation method, it's just slightly more complex to do so. – deceze Apr 03 '18 at 12:46
-
1If you really want to go that way, what keeps you from doing it in the exact same way? – Nico Haase Apr 03 '18 at 14:15
-
@deceze thanks can you please suggest a way to stop information being scraped ? – Sajan Kaundal Apr 04 '18 at 06:36
2 Answers
I would honestly recommend that you don't bother doing this.
Think about the reasons you want to do it. You probably want to stop people from stealing the data and using it for themselves, is that right?
The problem is, nobody steals data by manually copying and pasting it. If someone is going to steal your data, then they will use a scraping tool that will completely bypass the browser user interface, and will not be affected by any front-end system you put in place to prevent it.
On the other hand, blocking manual copy+pasting will affect your normal users who are probably not interested in stealing the data, but may want to copy it for legitimate reasons -- eg copying a phone number into an address book or so that they can dial it.
So by doing what you're asking for, you are annoying you real users, and not having any effect at all on the people you actually want to block. Seriously, don't do it.

- 4,952
- 3
- 19
- 29
-
Completely agreed with you but can you please suggest a way to stop data being scraped from website like Yellow pages and Yelp as their key data is say Restaurant Phone number. In this URL (( https://www.justdial.com/Delhi/Cafe-La-Pinoz-Near-Alchemist-Hospital-Sector-53/ ). its really hard to extract phone number as they are using some algorithm to randomly assign css class for number. – Sajan Kaundal Apr 04 '18 at 06:32
-
1@SajanKaundal - simply put, you can't. If the page can be viewed in a browser, then it can be scraped. You can maybe make it a bit harder, but ultimately once something can be downloaded, you have to assume it can be copied. – Simba Apr 04 '18 at 08:39
-
The best solution I can suggest is simply to write rock-solid terms and conditions and enforce them if you find anyone copying your work. A good trick for this is to include some "fake" data in your real database, to make it easy to spot when it's been copied. Mapping companies do this -- they make a few small deliberate errors in road layouts, which makes it easy for them to see if a competitor has copied their map instead of actually mapping the roads for themselves. – Simba Apr 04 '18 at 08:43
You can achieve that using jQuery also. You can use the below code to prevent users from copying and pasting text from your web pages through Ctrl+C Ctrl-V, or using the mouse. The code allows the user to select the text but he wont be able to copy the text from the page.
$('body').bind('copy paste cut drag drop', function (e) {
e.preventDefault();
});
Please find the sample jsfiddle here
UPDATE
if you would like to disable cut-copy-paste operations on certain fields – like the password input field or the text area, the following snippet should help. When the copy or cut event is fired, nothing happens.
$('input[type=text],textarea').bind('copy paste cut drag drop', function (e) {
e.preventDefault();
});
The above code will disable the copy operation for all the textboxes and textarea. You can implement the same for your control by replacing $('input[type=text],textarea') to your control.

- 2,318
- 6
- 19
- 37

- 1,619
- 4
- 25
- 55
-
Please check this URL ( https://www.justdial.com/Delhi/Cafe-La-Pinoz-Near-Alchemist-Hospital-Sector-53/ ) I am looking for something similar. Where scraping of phone number is not possible – Sajan Kaundal Apr 03 '18 at 12:16
-
@SajanKaundal have updated the code under update section. please refer it and modify it based on your control. – Karthik Venkatraman Apr 03 '18 at 12:41
-
By using above code copying data is prohibited but how to stop someone from scraping my content or make it more difficult like using ::before in CSS. – Sajan Kaundal Apr 04 '18 at 07:16