2

I am trying to scrape a website (believe it is in JavaScript) using a simple PHP script. I am a beginner so any help would be greatly appreciated. The URL of the webpage is:

http://www.indiainfoline.com/Markets/Company/Fundamentals/Balance-Sheet/Yes-Bank-Ltd/532648

So here for example I would like to pass the name of company (Yes-Bank-Ltd) and code (532648) in get_file_contents. Not sure on how to do it so can somebody please help.

Thanks, Nidhi

4
  • 2
    Scrap, as in "recycle"? You can try unlink, I suppose. Commented Jul 11, 2011 at 18:15
  • what do you mean by pass it, as I can see they are already in url Commented Jul 11, 2011 at 18:15
  • 1
    @Kerrek SB, he meant 'scrape'. Commented Jul 11, 2011 at 18:16
  • @Nightfirecat: Ahh, makes a lot more sense! Though I would have loved the idea of a website scrapyard, with lots of old queries and dying animated GIFs... Commented Jul 11, 2011 at 18:17

3 Answers 3

1

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....
 }
Sign up to request clarification or add additional context in comments.

5 Comments

Ok, seems to be a good idea. However, when i try using hte syntax you gave here, it is giving a problem. Can you please verify if you need two quotes in the first variable and no quotes after the second one.
Are you a developer? Quotes verifications should be your job to check. It's just a pseudo code to show you how to solve your problem.
no, i am not a developer, and hence the issue.. sorry for causing you trouble
Stackoverflow is not a place to get code all made for you project but a place to ask question. Sorry I can't give you more than that, I evaluate my answer as a good start. You should get some PHP tutorial and come back here because string concatenation is basic stuff.
Ok, i figured it out. I was using the command inside a single quote and not a double quote. Now this is working. BTW, would you know how i can run a javascript on the page that i am scrapping. In this case, i want consolidated results and hence javasript:_doPostBack()
0

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/

Comments

-1

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

1 Comment

sorry, i do not find Yahoo! website useful for Indian Companies

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.