如果您检查html,您将看到表单的操作是
../cgi-bin/statos_OIB.cgi
http://www.hzzo-net.hr/cgi-bin/statos_OIB.cgi
,因此必须使用该url。
另外,在一些测试之后,我发现服务器返回500个响应,除非一个有效的referer(
http://www.hzzo-net.hr/statos_OIB.htm
我不熟悉R,但是我可以用Python提供一个例子,使用
requests
图书馆。
import requests
url = "http://www.hzzo-net.hr/cgi-bin/statos_OIB.cgi"
hzzo_response = 'your token'
data = {
'upoib': '93335620125',
'g-recaptcha-response': hzzo_response
}
headers = {'referer': 'http://www.hzzo-net.hr/statos_OIB.htm'}
r = requests.post(url, data=data, headers=headers)
html = r.text
print(html)
httr
我设法在R中“翻译”了上面的代码。如果提供了有效的令牌,代码将产生正确的结果。
library(httr)
url <- "http://www.hzzo-net.hr/cgi-bin/statos_OIB.cgi"
hzzo_response <- "your token"
parameters <- list(
'upoib' = "93335620125",
'g-recaptcha-response' = hzzo_response
)
test <- POST(
url,
body = parameters,
add_headers(Referer = 'http://www.hzzo-net.hr/statos_OIB.htm'),
encode = "form",
verbose()
)
html <- content(test, 'text', encoding = 'UTF-8')
print(html)