Scrape a website (javascript website) using php

你离开我真会死。 提交于 2019-12-06 09:54:53

Why aren't you just not append the string of the company and code in the url. Here is an idea that you fill up an array of company and code (need to be the same size) and then you loop them to scrape the data you want.

for($i=0;$i<count($listOfCie);$i++)
{
    $cie = $listOfCie[$i];
    $code = $listOfCode[$i];
    $urlToScrape = "http://www.indiainfoline.com/Markets/Company/Fundamentals/Balance-Sheet/" . $cie . "/" . $code
    //... = get_file_contents($urlToScrape....
 }

Use the data.html table in YQL! http://developer.yahoo.com/yql/console

The simplest way to scrape a site in PHP is to use curl (http://php.net/manual/en/book.curl.php)

For some examples look at http://php.net/manual/en/curl.examples-basic.php or google :)

If the website relies on javascript though it's going to be difficult to get the data you want. You might look at a "headless browser" like http://phantomjs.org/

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