B0b Posted October 4, 2009 Share Posted October 4, 2009 Hi guys, I must know if there's any way to obtain the page HTML after some content has been dynamically added via Javascript (AJAX). For example, the description of an item on eBay doesn't appear in the source code of the page... is there anyway to still grab the page HTML with the description (curl_setopt)? Thank you very much. Link to comment https://forums.phpfreaks.com/topic/176491-urgent-possible-to-obtain-pages-html-of-dynamically-added-text/ Share on other sites More sharing options...
The Little Guy Posted October 5, 2009 Share Posted October 5, 2009 I think you have to know where the html came from, from the ajax... For example you view: http://ebay.com/somepage and the ajax comes from: http://ebay.com/anotherpage you would have to get the html from there. I am not sure, but that is my BEST guess Link to comment https://forums.phpfreaks.com/topic/176491-urgent-possible-to-obtain-pages-html-of-dynamically-added-text/#findComment-930345 Share on other sites More sharing options...
thebadbad Posted October 5, 2009 Share Posted October 5, 2009 I guess you would need a javascript parser for that. But going along the lines of The Little Guy's post, I found out that the eBay descriptions are retrieved from http://vi.ebaydesc.com/ws/eBayISAPI.dll?ViewItemDescV4&item=ID where ID is the item ID. So starting out with a sample URL like http://cgi.ebay.com/ASKSOS-ROMAN-EGYPTIAN-FRAGMENTARY-1600-YEARS-OLD-NR_W0QQitemZ380163697044QQcmdZViewItemQQptZLH_DefaultDomain_0?hash=item588385a994&_trksid=p3286.c0.m14 we can grab the item ID directly from the URL and then get the description. eBay uses their own query string syntax, with QQ instead of &, and Z instead of =, in case you didn't notice. <?php $url = 'http://cgi.ebay.com/ASKSOS-ROMAN-EGYPTIAN-FRAGMENTARY-1600-YEARS-OLD-NR_W0QQitemZ380163697044QQcmdZViewItemQQptZLH_DefaultDomain_0?hash=item588385a994&_trksid=p3286.c0.m14'; preg_match('~QQitemZ([0-9]+)QQ~', $url, $match); $desc_url = "http://vi.ebaydesc.com/ws/eBayISAPI.dll?ViewItemDescV4&item={$match[1]}"; ?> Link to comment https://forums.phpfreaks.com/topic/176491-urgent-possible-to-obtain-pages-html-of-dynamically-added-text/#findComment-930350 Share on other sites More sharing options...
redarrow Posted October 5, 2009 Share Posted October 5, 2009 thebadbad << the only reason that done so general wannabe hackers don't do what you just shown them to do so easily. got to be very careful what you show people on phpfreaks even Theo there no harm caused. i hope ebay is more security minded then that are they?. Link to comment https://forums.phpfreaks.com/topic/176491-urgent-possible-to-obtain-pages-html-of-dynamically-added-text/#findComment-930411 Share on other sites More sharing options...
jon23d Posted October 5, 2009 Share Posted October 5, 2009 Ebay also offers a robust and freely-available api that can make life a lot easier once you learn it. Link to comment https://forums.phpfreaks.com/topic/176491-urgent-possible-to-obtain-pages-html-of-dynamically-added-text/#findComment-930494 Share on other sites More sharing options...
thebadbad Posted October 5, 2009 Share Posted October 5, 2009 thebadbad << the only reason that done so general wannabe hackers don't do what you just shown them to do so easily. got to be very careful what you show people on phpfreaks even Theo there no harm caused. i hope ebay is more security minded then that are they?. I'm pretty sure that's not the only reason they're doing it. And it's not like I'm revealing some dark secrets of hacking; the data is publicly available (not necessarily meaning that you're free to do anything with it though). But if they offer an API like jon23d mentions, you might as well just use that instead. That is if the OP actually wanted to grab the data from eBay, and not just mentioned it as a pure example. Link to comment https://forums.phpfreaks.com/topic/176491-urgent-possible-to-obtain-pages-html-of-dynamically-added-text/#findComment-930607 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.