using curl to get from one webpage to another involving javascript

血红的双手。 提交于 2020-01-25 10:01:19

问题


I have webpage1.html which has a hyperlink whose href="some/javascript/function/outputLink()"

Now, using curl (or any other method in php) how do I deduce the hyperlink (of http:// format) from the javascript function() so that I can go to next page.

Thanks


回答1:


You'd have to scrape the JavaScript. Figure out where the function is and see what URL it's using.

Sometimes http:// is omitted for links that are on the same page, so that won't be a good search reference.

At this point the only valuable thing to do is to try and understand the JavaScript code yourself, and once you find the link you could use regex to filter the result programmatically with PHP.

preg_match("/url + \'\/apples.html/g", "blah blah var javaScriptVar= url + '/apples.html';", $matches);



回答2:


There is no straight forward way. There are very few to zero libraries which can perfectly do what you require. I think http://www.dapper.net/ is something close to what you want. I am not sure if its the ideal solution. Dapper.net will help you parse text and links and would probably also handle javascript.



来源:https://stackoverflow.com/questions/2013266/using-curl-to-get-from-one-webpage-to-another-involving-javascript

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