I\'m trying to do a simple post request on the main search bar of http://forums.egullet.org/. (This is one example, but I\'m trying to build a tool that will work with many
I think you need an ampersand where you have a question mark
argumentString = "&search_term=eggs&search_app=forums"
To make it more concise and get the title of that target page:
Sub httpPost()
Dim http As New XMLHTTP60, html As New HTMLDocument
Dim post As Object, argstr As String
argstr = "type=all&q=eggs"
With http
.Open "POST", "https://forums.egullet.org/search/?", False
.setRequestHeader "User-Agent", "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36"
.setRequestHeader "Content-type", "application/x-www-form-urlencoded"
.send argstr
html.body.innerHTML = .responseText
End With
For Each post In html.getElementsByClassName("ipsStreamItem_title")
With post.getElementsByTagName("a")
If .Length Then Row = Row + 1: Cells(Row, 1) = .Item(0).innerText
End With
Next post
End Sub