Obtain updated information from other sites and post on your site in PHP
Good Day all,
I have an existing site built. I was wondering, how can my site update automatically when another website updates too? This essentially means that my existing site will obtain information like Cost, Description, images from the other site upon update.
I was开发者_C百科 pondering web services but the other site doesn't have it.
Please advise!
Thanks!
If the other site doesn't have an API, your only option is page scraping, i.e. downloading the HTML and parsing it to extract the info you want.
If they have a page structure that doesn't change often, this is generally reliable.
You'd probably want to use PHP's DomDocument to extract the info.
Generally, people don't like it because badly designed tools can tax their system resources, since generating a whole HTML page is more resource intensive than generating an API response.
Page scraping is fairly widespread, though some people discourage it. It may be disallowed by the TOU of a site, possibly having legal implications. Or, your target site may have no problem with it. There are of course large businesses built on page scraping (see 'Google').
精彩评论