How Best Can I Read DOM Of External Pages? - Programming - Nairaland
Nairaland Forum › Science/Technology › Programming › How Best Can I Read DOM Of External Pages? (1347 Views)
| How Best Can I Read DOM Of External Pages? by Desyner(op): 1:25am On Aug 28, 2017*. Modified: 11:39pm On Oct 14, 2017 |
Hello Nairalanders, I want to read the content of external sites dynamically and don't know which technology suitable and best for this. I want to go into pages and search of its content divs, p, a , images and span tags and read their contents for onward manipulation. Can JSON do it? I was thinking of using researching Java 8's Networking API for this purpose but would love a simply solution like PHP. |
| Re: How Best Can I Read DOM Of External Pages? by phainix: 9:17am On Aug 28, 2017 |
Hi Desyner, im not sure what you want to achieve but with php you can use 'file_get_contents', it'll fetch all the html code on the page and you can probably do your sorting from there
|
| Re: How Best Can I Read DOM Of External Pages? by Desyner(op): 10:27am On Aug 28, 2017 |
@phainix, I will try it out even though i found what looks like the java version of the solution. Thanks for the PHP solution, it uses less memory compared java. I will explore it also. |
| Re: How Best Can I Read DOM Of External Pages? by agwaisrael(m): 10:50am On Aug 28, 2017 |
When you get the site contents, there are libraries to parse html as xml in php. This has nothing to do with networking apis. You only need a simple ; HttpURLConnection adam = (HttpURLConnection) URL.connect(); adam.getInputStream();... on java Or file_get_contents(url);... for php Search for w3 html parsers or create your own library to parse what you need |
| Re: How Best Can I Read DOM Of External Pages? by yorex2011: 9:47pm On Aug 28, 2017 |
Use simple html dom for php After you may have used file get contents or curl |
| Re: How Best Can I Read DOM Of External Pages? by Olyboy16(m): 12:22am On Aug 29, 2017 |
Desyner:I don't know exactly how you want to interact with the data, but check PhantomJs http://phantomjs.org |
| Re: How Best Can I Read DOM Of External Pages? by orimion(m): 4:12pm On Aug 29, 2017 |
Sounds like you want to do web scraping, search for a web scraping library in your language of choice |
| Re: How Best Can I Read DOM Of External Pages? by Nobody: 3:53pm On Aug 31, 2017 |
Kindky pay a visit to php |
| Re: How Best Can I Read DOM Of External Pages? by jamesmalvi(m): 10:35am On Sep 05, 2017 |
Desyner:Yes, JSON can do it. here is tool, which may help: https://jsonformatter.org |
Code For Constructing The DOM From HTML • In Need Of External Hard Drive For Sale • NCDC Coronavirus Updates Brute, Efficient, Fast DOM Php Code • 2 • 3 • 4
Get Free Host And Free Domain Name Forever (trending) • Are You A Programmer; Web-software-app Developers. There Is A Job 4 U • I Need A Mobile App Developer