Ramesh Deo
Member
Hi All,
Hope you doing well and appreciate any help in web scrapping. I have to find out published and not published articles by their quotes which is given in attached example file on https://finance.yahoo.com/quote/DTE and https://beta.finance.yahoo.com/quote/DTE as well.
Here DTE is the quote which is in column B. and the method is to open this webpage for these quotes and then find their articles which is in column A and these articles is tagged in both webpage as hyperlink. for example the quote DTE given in above link and now i need to find the article published on https://finance.yahoo.com/quote/DTE and https://beta.finance.yahoo.com/quote/DTE
"DTE Energy Is Expected to Report Lower Sales in 2Q16"
here is screenshot attached for reference below.
same in Yahoo beta.
Now I want result in column C if these articles tagged on both as "Available" for their quotes which I have. if not tagged then result would be their quotes in column C which is in column B and so on so forth.
Note sometime the articles tagged under summary and sometimes its under News because its depend on quotes where its tagged.
here is screenshot for reference.

I tried to do this but I failed. Here is my code below.
Sub dataextract_yahoo()
'the_start:
On Error Resume Next
Dim ie As New InternetExplorer
Dim i As Long
Dim lr As Long
Dim quotes As String
Dim tst As Variant
'Dim ydate As String
Dim article As String
lr = Sheet1.Cells(Rows.Count, 3).End(xlUp).Row + 1
i = 2
quotes = Sheet1.Range("B" & i).Value
article = Sheet1.Range("A" & i).Value
ie.Visible = True
'On Error Resume Next
ie.navigate "http://finance.yahoo.com/quote/" & quotes
Do
DoEvents
' If Err.Number <> 0 Then
' ie.Quit
' Set ie = Nothing
' GoTo the_start
' End If
Loop Until ie.readyState = READYSTATE_COMPLETE
'Application.StatusBar = " loading website.."
Dim doc As HTMLDocument
Dim output As Object
Dim tst As Variant
Set doc = ie.document
Set output = doc.getElementsByTagName("div")
For Each tst In output
If tst.innerText = article Then
Sheet1.Range("C" & lr).Value = "Available"
Else
Sheet1.Range("C" & lr).Value = quotes
End If
Next tst
ie.quite
i = i + 1
End Sub
Thanks for any help!!
Hope you doing well and appreciate any help in web scrapping. I have to find out published and not published articles by their quotes which is given in attached example file on https://finance.yahoo.com/quote/DTE and https://beta.finance.yahoo.com/quote/DTE as well.
Here DTE is the quote which is in column B. and the method is to open this webpage for these quotes and then find their articles which is in column A and these articles is tagged in both webpage as hyperlink. for example the quote DTE given in above link and now i need to find the article published on https://finance.yahoo.com/quote/DTE and https://beta.finance.yahoo.com/quote/DTE
"DTE Energy Is Expected to Report Lower Sales in 2Q16"
here is screenshot attached for reference below.

same in Yahoo beta.
Now I want result in column C if these articles tagged on both as "Available" for their quotes which I have. if not tagged then result would be their quotes in column C which is in column B and so on so forth.
Note sometime the articles tagged under summary and sometimes its under News because its depend on quotes where its tagged.
here is screenshot for reference.

I tried to do this but I failed. Here is my code below.
Sub dataextract_yahoo()
'the_start:
On Error Resume Next
Dim ie As New InternetExplorer
Dim i As Long
Dim lr As Long
Dim quotes As String
Dim tst As Variant
'Dim ydate As String
Dim article As String
lr = Sheet1.Cells(Rows.Count, 3).End(xlUp).Row + 1
i = 2
quotes = Sheet1.Range("B" & i).Value
article = Sheet1.Range("A" & i).Value
ie.Visible = True
'On Error Resume Next
ie.navigate "http://finance.yahoo.com/quote/" & quotes
Do
DoEvents
' If Err.Number <> 0 Then
' ie.Quit
' Set ie = Nothing
' GoTo the_start
' End If
Loop Until ie.readyState = READYSTATE_COMPLETE
'Application.StatusBar = " loading website.."
Dim doc As HTMLDocument
Dim output As Object
Dim tst As Variant
Set doc = ie.document
Set output = doc.getElementsByTagName("div")
For Each tst In output
If tst.innerText = article Then
Sheet1.Range("C" & lr).Value = "Available"
Else
Sheet1.Range("C" & lr).Value = quotes
End If
Next tst
ie.quite
i = i + 1
End Sub
Thanks for any help!!