How to get hover data(ajax) by any crawler php

﹥>﹥吖頭↗ 提交于 2019-12-06 03:01:56

Hover data can't be obtained by any crawlers.

Crawlers crawl the web page and gets whole data ( HTML page source ). It's view which we can view as soon as we hit URL. Hover need mouse moving action over HTML attribute on page i.e manual action. And currently no crawlers do actions for hovering and getting that data as per my knowledge. So this is not possible to get hover data by crawlers.

One possibility is to execute the javascript using a javascript interpeter (took a quick look at this http://php.net/manual/en/book.v8js.php and it may be what you need) and then write some additional javascript code to fire the hover events on the necessary elements.

If the page is using AJAX to fill in the necessary fields, it may be easier to use a tool like Firebug to view the AJAX calls and recreate these in your code to fill in the missing DOM elements.

Another alternative is to rethink the crawler and perhaps use a browser-based crawler. This is something I don't have much experience with but I'm sure others have done this.

I suggest looking into Selenium. I've used it many times and it can definitely do onmouseover

You cannot obtain dynamic source code that requires user interaction with simple php curl. However, with PhantomJS you can achiever hover state and also grab future ajax loading of a page. It has a learning curve and you need to install it with node.js in your server see if you have rights.

With PhantomJS you will be able to get onmouseover or dynamic ajax content since it's a headless webkit browser that visits pages with your commands.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!