0

I want to develop a script which will extract certain information from client side when he enter url for our site.

For exmaple-:If he enter the url www.example.com,the code intiates and extract certain information from the client side.It will be different for each user like facebook email etc.

So I was looking at the option and thinking it is nearly impossible to do so unless I have some kind of javascript code which will execute on client side whenever he visit the site.I am also looking at libraries such as Jsoup,selenium etc but I guess they are only executes locally and it didn't solve my purpose.

The text I want to extract is in iframe and further in tables.So is it possible to write a code (javascript or something else )which I include in our index.php page and it executes on client site,extract the information and store the results in database?

The scenario is if user is already logged in into facebook on the same browser then when he visit my site,it will automatically displays his email id related to facebook.So I want to extract that email id.Any suggestions?

EDIT-->>

I am trying the following code to move to frame and then get the content but it is returning empty content document.

var iframe = document.evaluate('//iframe[contains(@src, \"//my.leadpages.net/forms/5620062778032128/5654100301578240/5645914630782976/html/?lp-in-iframe=1\")]',document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).contentDocument;alert(iframe);

Also if you can guide me through for how can I move to frame and then get it's contents via nodes.Iframe has no id,name etc so I have used xpath way.It is detecting the frame as resulting XpathResult but I am not sure how to move into it and then extract text for various nodes.This has to be in Javascript.

gariepy
  • 3,576
  • 6
  • 21
  • 34
Anish Sharma
  • 115
  • 1
  • 2
  • 9
  • [I need to extract somehow (probably using JavaScript) some information in my clients' websites. What's the best way to do it?](http://stackoverflow.com/questions/8010101/i-need-to-extract-somehow-probably-using-javascript-some-information-in-my-cli?rq=1) – DavidPostill Jun 28 '14 at 08:18
  • @DavidPostill The scenario is if user is already logged in into facebook on the same browser then when he visit my site,it will automatically displays his email id related to facebook.So I want to extract that email id.Any suggestions? – Anish Sharma Jun 29 '14 at 05:07
  • So if I visit your website you will **automatically** retrieve my facebook login email? No thanks! The proper way to do this is to **ask** users to login to your site using their facebook account. See [Using Facebook Login with Existing Login Systems](https://developers.facebook.com/docs/facebook-login/multiple-providers) for a more accepted way to do this (which gives the user control over what happens next) – DavidPostill Jun 29 '14 at 07:34
  • @DavidPostill If user has a facebook session maintained on the same browser then the site automatically knows the user facebook email(I don't know how may be some oAuth etc).When user click on a button then it displays a popup which is in a iframe showing the user his facebook name and email and asking him to confirm that he want to login into acc.What I want is that which is already their. – Anish Sharma Jun 30 '14 at 11:35
  • @AnishSharma Have you checked that [link](http://my.leadpages.net/forms/5620062778032128/5654100301578240/5645914630782976/html/?lp-in-iframe=1) within the provided code? You're talking about facebook but it has to do nothing with this link. I see an empty form. However, if that iframe already has a content on the page/location a) why would you inject it to another page/location b) to get the same content?! – hex494D49 Jun 30 '14 at 12:47

3 Answers3

0

I'm pretty sure the browsers won't let you access contents of an iframe. Also this thing you're trying to achieve sounds smoewhat shady to me. Why do you want to take data that your user didn't give to you explicitly?

megapctr
  • 931
  • 1
  • 7
  • 19
  • The scenario is if user is already logged in into facebook on the same browser then when he visit my site,it will automatically displays his email id related to facebook.So I want to extract that email id.Any suggestions? – Anish Sharma Jun 28 '14 at 08:47
  • @pctr Of course I can access content of an iframe, or whatever part of html (source page). – hex494D49 Jun 29 '14 at 09:13
0

Well, in order to do something relating and specific to each user, you need to have a membership system on your server-side; in other words, your users must be logged in. This is rather a complex system than a small snippet of code, but in pseudo-code it may looks as following

// on you server side, using PHP, C#, Java ...
if(is_current_user_logged_in(some_user)){
    // at this point you know who's the user so
    // do whatever you need
}
hex494D49
  • 9,109
  • 3
  • 38
  • 47
  • The scenario is if user is already logged in into facebook on the same browser then when he visit my site,it will automatically displays his email id related to facebook.So I want to extract that email id.Any suggestions? – Anish Sharma Jun 29 '14 at 05:08
  • If you need a proper/clean way to do it, maybe this [post](http://stackoverflow.com/questions/3611682/facebook-graph-api-how-to-get-users-email) may help you. But your comment sounds to me like you want to extract/scrap that data from the source page/html (in this case); if so, show me that fragment of html code where that data is written. – hex494D49 Jun 29 '14 at 08:36
  • If user has a facebook session maintained on the same browser then the site automatically knows the user facebook email(I don't know how may be some oAuth etc).When user click on a button then it displays a popup which is in a iframe showing the user his facebook name and email and asking him to confirm that he want to login into acc.What I want is that which is already their. – Anish Sharma Jun 30 '14 at 11:36
0

The proper way to do this is to ask users to login to your site using their facebook account.

See Using Facebook Login with Existing Login Systems for a more accepted way to do this (which gives the user control over what happens next)

DavidPostill
  • 7,734
  • 9
  • 41
  • 60
  • If user has a facebook session maintained on the same browser then the site automatically knows the user facebook email(I don't know how may be some oAuth etc).When user click on a button then it displays a popup which is in a iframe showing the user his facebook name and email and asking him to confirm that he want to login into acc.What I want is that which is already their. – Anish Sharma Jun 30 '14 at 11:36