0

I'm looking to get some data from a Facebook page of a restaurant, but I'm kinda stuck. I want to load some divs from the facebook page of the restaurant, then get the ID's of the divs, since they contain some information i would like to use. Ive tried using the .load function from jQuery, but no luck. Of all the answers I've seen, they all include a url that's something like somefile.html. Is it possible to load the divs ids and some innerHTML from a live page like Facebook? Are they somehow downloading the html to a file then using that? Keep in mind I know nothing about PHP, so any solutions? Thanks!

7
  • 2
    What you are describing goes against facebook's policy here: facebook.com/apps/site_scraping_tos_terms.php Commented Jun 18, 2018 at 21:28
  • Nu uh, we ain't gonna help you with that, as the comment by @Juan points out it's against their policy Commented Jun 18, 2018 at 21:31
  • I cant collect simple things like div id's even though everyone can just inspect element and see the id, also im looking to collect the div id's of only 2-3 restaurants, is that still a problem ? Commented Jun 18, 2018 at 21:33
  • @AndrejGeorgiev What the other users are saying is Facebook's Usage Policy essentially forbids "web scraping" Facebook pages, which is what you're trying to do. Commented Jun 18, 2018 at 21:34
  • Oh, feel like a criminal right now, quess il stop, thanks so much! Commented Jun 18, 2018 at 21:35

2 Answers 2

2

The right way to do it would be though Facebooks graph API, take a look at this site and see if it offers the information you need https://developers.facebook.com/docs/graph-api/reference/page/

Sign up to request clarification or add additional context in comments.

1 Comment

That is the correct and legal way to do +1 vote for you sir
0

NOTE

As comments have pointed out, "web scraping" is FORBIDDEN on Facebook.com by Facebook policy. http://www.facebook.com/apps/site_scraping_tos_terms.php


Technically, I don't think this is possible with Facebook and just JavaScript.

In general, using just JavaScript, one solution would be to load the (external) site like FaceBook into an Iframe, and then grab all the DIVs and search the DOM that's loaded into the iFrame. However, I believe FaceBook (and other sites) set something called "CORS Request Headers" which prevent the page from loading into an iFrame -- also, as far as I know, this cannot be hacked around except to use another language to pull the HTML as a file (like with PHP).

Sources:

  1. Facebook Forbids iFrames
  2. JavaScript, Load Page in iFrame

1 Comment

So would this be possible with PHP, also would it be legal, considering what the other people are commenting?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.