1

I am trying to web scrape Zillow. I am currently using web automation however, I cannot search my desire location. The value appears on the search bar, but when it submits it doesn't change it goes back to the same page. It is like the value pre-established stays there even though I change it. Please help me, I've been trying for so many days and I can't get answers.

Zillow's code.----------------------------------------------------------------------------------


<input class="react-autosuggest__input" role="combobox" aria-expanded="false" aria-controls="react-autowhatever-1" aria-owns="react-autowhatever-1" aria-autocomplete="list" aria-label="Search: Suggestions appear below" type="text" placeholder="Address, neighborhood, or ZIP" value="new jersey" autoComplete="off">
Sub zillow()


Dim ie As New SHDocVw.InternetExplorer
Dim doc As MSHTML.HTMLDocument
Dim zillowinput As MSHTML.IHTMLElementCollection
Dim zillowinput2 As MSHTML.IHTMLElementCollection
Dim direc As String
Dim iny As MSHTML.IHTMLElementCollection
Dim inys As MSHTML.IHTMLElement

ie.Visible = True
ie.navigate "https://www.zillow.com/homes/new-jersey_rb/"

Do While ie.readyState <> READYSTATE_COMPLETE Or ie.Busy

Loop`enter code here`

Set doc = ie.document

direc = Range("D5").Value

Application.Wait Now() + #12:00:02 AM#

Set inys = doc.getElementById("srp-search-box")
Set inys = doc.getElementsByTagName("input")(0)
  inys.Focus
  inys.Value = "35 Krakow St, Garfield, NJ 07026"
  inys.Blur

**strong text**

doc.forms(0).submit
Ye West
  • 13
  • 2
  • The text field has a `change event`. I'm pretty sure you must trigger it to make your address text working for the page. Here you can look how to get information about the events for an html element and how do deal with them: https://stackoverflow.com/questions/63294113/automate-ie-via-excel-to-fill-in-a-dropdown-and-continue/63299608#63299608 – Zwenn Apr 18 '21 at 12:01
  • In case you are not aware of it, Zillow has API and you should consider if it's possible for your purpose https://www.zillow.com/howto/api/faq.htm – Raymond Wu Apr 18 '21 at 13:22
  • @zwenn I've tried, but no success. I am really confused, I don't know why it isn't working. – Ye West Apr 18 '21 at 22:03

1 Answers1

0

The change event in the search box can be fired with SendKeys. You can simulate user input using SendKeys to set value of the search box and press Enter to do the search.

You can refer to the working code below:

Sub zillow()

Dim ie As New SHDocVw.InternetExplorer
Dim doc As MSHTML.HTMLDocument
Dim inys As MSHTML.IHTMLElement

ie.Visible = True
ie.navigate "https://www.zillow.com/homes/new-jersey_rb/"

Do While ie.readyState <> READYSTATE_COMPLETE Or ie.Busy

Loop

Set doc = ie.document

Application.Wait Now() + #12:00:02 AM#

Set inys = doc.getElementsByTagName("input")(0)
  inys.Focus
  SendKeys ("35 Krakow St, Garfield, NJ 07026")
  Application.Wait (Now + TimeValue("00:00:02"))
  SendKeys ("{ENTER}")

End Sub

Result in IE:

enter image description here

Yu Zhou
  • 11,532
  • 1
  • 8
  • 22