I was wondering how I would be able to parse a url after loading it through a users IP address. I want to know this because for this site I want to parse it loads a new key with everyones IP address. So when I parse it through file_get_contents of cURL, it gives me the default value and not the unique key. The only way I though of it to work was to load the page in an iframe then get the source of the iframe. However, I don't know if this is possible. If this is or if you guys know of a way I can do this please let me know. Thanks!

share|improve this question
feedback

2 Answers

You say you're trying to parse a URL, so use parse_url.

But it also sounds like you mean you want to parse the HTML in the page results, in which case you should use a DOM parser. See http://htmlparsing.com/php.html for examples of how to properly parse HTML with PHP modules. If anyone tells you to use regular expressions to parse your HTML, ignore them.

share|improve this answer
So will this way load it first then parse? Because with the file_get_contents I parsed the HTML with strpos and stuff and it generated the url successfully but it wasn't unique to the persons IP address, would this method be? – user1933224 Dec 30 '12 at 6:40
I don't understand the details of what exactly you are trying to extract from the HTML. Perhaps you should amend your post to give more details. As to having "parsed the HTML with strpos and stuff", that is not a safe way to parse HTML. You want to use a HTML parser like DOM – Andy Lester Dec 30 '12 at 6:46
feedback

Sounds like you need the user to actually get the url from their own computer and send you the results. Why not load the url into the iframe, then use an ajax function to send the contents of the iframe back to your site, act on it and redirect if necessary.

See this conversation about using jquery to act on content loaded into an iframe iframe contents change event?

See the jquery ajax documentation on how to submit this information to your own php files http://api.jquery.com/jQuery.ajax/

Not sure if this is what you wanted but it's what you might have to do in order to get the url's content as your user's ip address.

share|improve this answer
Yes, I want to get the source code of the iframe, and I said above. However, I read that you can;t get the source code of an iframe if it is not on your own server. – user1933224 Dec 30 '12 at 6:52
Your right on that, looks like your pretty limited less asking the user to save the page and upload it to you. Or asking them to install some browser plugin that might forward you content as the user see's it. Likely this kind of stuff would be seen as intrusive. – Dan Mayor Dec 30 '12 at 6:59
feedback

Your Answer

 
or
required, but never shown
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.