0

get newsheader from yahoo finance with xpath

Hello,
I am trying to get all the links to newheaders on a certain ticker. I was able to get the list from the main page of finance (after inserting a ticker) using this yql:

select * from html where url="http://finance.yahoo.com/q?s=amzn" and xpath='//div[@id="yfi_headlines"]/div[2]/ul/li/a'

But i can't get all the results. So i tried using the same idea on the page that shows all the result (the link to the page: http://finance.yahoo.com/q/h?s=AMZN&t=...T10:00:00-05:00 )

with this yql:

select * from html where url="http://finance.yahoo.com/q/h?s=AMZN&t=2009-11-15T10:00:00-05:00" and xpath='//table[@id="yfncsumtab"]/tbody/tr[2]/td/table[2]/tbody/tr/td[2]/a'

(I used firebug in order to follow the page DOM). But this gives me no results. Anyone can please show me what is the problem? Or suggest a better way to do this?
Thank you

by
4 Replies
  • QUOTE (yehudasabag @ Nov 15 2009, 08:35 AM) <{POST_SNAPBACK}>
    select * from html where url="http://finance.yahoo.com/q/h?s=AMZN&t=2009-11-15T10:00:00-05:00" and xpath='//table[@id="yfncsumtab"]/tbody/tr[2]/td/table[2]/tbody/tr/td[2]/a'

    (I used firebug in order to follow the page DOM). But this gives me no results. Anyone can please show me what is the problem? Or suggest a better way to do this?
    Thank you


    Firefox/Firebug tends to insert tbody elements that don't really exist into the DOM. Try removing the tbody elements and see if it works then.
    0
  • QUOTE (sh1mmer @ Nov 16 2009, 11:48 AM) <{POST_SNAPBACK}>
    Firefox/Firebug tends to insert tbody elements that don't really exist into the DOM. Try removing the tbody elements and see if it works then.


    Hi, Thanks for the reply. You are right about the tbody, the fire bug indeed added it. But even when i deleted it i am still can't get it to work.
    Any other suggestins ? (Sorry about the time it took me to reply, next time it will be faster...)

    Thanks
    0
  • how did you delete the tbody element?
    0
  • QUOTE (Matthew R @ Nov 19 2009, 02:05 PM) <{POST_SNAPBACK}>
    how did you delete the tbody element?


    Well, i figured it up. Sorry about the time it took be to bring the answer.
    The yql is:

    select * from html where url="http://finance.yahoo.com/q/h?s=AMZN&t=2009-11-15T10:00:00-05:00" and xpath='//table[@id="yfncsumtab"]/tr/td/table/tr/td/table[2]/tr/td[2]/a

    I just did a mistake in the DOM path.

    About the tbody, i just deleted it from the path.
    0

Recent Posts

in YQL