I’m building a PHP app that allows a user to upload an ad and preview it on specific pages of a specific website. Right now, I’m doing it by taking screenshots of the webpage, removing the ads, and placing my own s. This seems pretty stupid.
What would be the best way to get the contents of a URL and replace code that appears between a certain on that page?
DOMDocumentobjectXPathon theDOMDocumentobjectExample:
The example loads the source of
example.comand replaces the logo withgoogle.com‘s logo and a link to google.The code does not have any validation but should be pretty easy to modify for your needs 🙂